From fb85944d6bc6ad06c93c9e09206477b75175913f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Fri, 12 Feb 2021 11:32:37 +0100 Subject: [PATCH 001/109] create minified std.scm file --- Makefile | 6 +- README.md | 10 +- bin/lips.js | 2 +- dist/lips.js | 14 +- dist/std.min.scm | 685 +++++++++++++++++++++++++++++++++++++++++++++ lib/js/bookmark.js | 2 +- scripts/minify.scm | 9 + templates/Makefile | 6 +- 8 files changed, 718 insertions(+), 16 deletions(-) create mode 100644 dist/std.min.scm mode change 100644 => 100755 lib/js/bookmark.js create mode 100755 scripts/minify.scm diff --git a/Makefile b/Makefile index 1c25c64a..f0077b92 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,9 @@ MERMAID=./node_modules/.bin/mmdc NPM=npm UGLIFY=./node_modules/.bin/uglifyjs ROLLUP=./node_modules/.bin/rollup +LIPS=./bin/lips.js -ALL: Makefile package.json .$(VERSION) assets/classDiagram.svg dist/lips.js dist/lips.min.js README.md dist/std.scm +ALL: Makefile package.json .$(VERSION) assets/classDiagram.svg dist/lips.js dist/lips.min.js README.md dist/std.min.scm dist/lips.js: src/lips.js .$(VERSION) rollup.config.js $(ROLLUP) -c @@ -48,6 +49,9 @@ dist/lips.min.js: dist/lips.js .$(VERSION) dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm > dist/std.scm +dist/std.min.scm: dist/std.scm + $(LIPS) ./scripts/minify.scm dist/std.scm > dist/std.min.scm + Makefile: templates/Makefile $(SED) -e "s/{{VER""SION}}/"$(VERSION)"/g" templates/Makefile > Makefile diff --git a/README.md b/README.md index 19afdd4f..e39e4b77 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/master/assets/lips.svg?raw=true) +![LIPS - Scheme Based Powerful Lisp Language](https://github.com/jcubic/lips/blob/devel/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) ![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=master&e90dcac3b5fcfcd4c1fade75f9cf3aded52bacd5)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=master&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=master) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&e03fd96e5d4b588bb149ed2f2db2296885f8d98d)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&4bc93f9a519c2e3dab7277f4f453e29b)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) @@ -196,7 +196,7 @@ npm install -g @jcubic/lips you can run the interpreter from the terminal: -![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/master/assets/screencast.gif?raw=true) +![LIPS: Scheme interactive terminal](https://github.com/jcubic/lips/blob/devel/assets/screencast.gif?raw=true) You can also run code in a string with: diff --git a/bin/lips.js b/bin/lips.js index ed7db8e7..79919b02 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -223,7 +223,7 @@ if (options.version || options.V) { const dynamic = options.d || options.dynamic; return run(code, interp, dynamic).then(print); }); -} else if (options._.length === 1) { +} else if (options._.length >= 1) { // hack for node-gtk const rl = readline.createInterface({ input: process.stdin, diff --git a/dist/lips.js b/dist/lips.js index 6e909ba0..db4af057 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -4,7 +4,7 @@ * | | \ \ | | | || . \/ __> | | * | | > \ | |_ | || _/\__ \ | | * | | / ^ \ |___||_||_| <___/ | | - * \_\ /_/ \_\ /_/ v. 1.0.0-beta.11 + * \_\ /_/ \_\ /_/ v. DEV * * 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: Sun, 31 Jan 2021 11:47:57 +0000 + * build: Fri, 12 Feb 2021 10:31:11 +0000 */ (function () { 'use strict'; @@ -13034,10 +13034,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 31 Jan 2021 11:47:57 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 12 Feb 2021 10:31:11 +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('Sun, 31 Jan 2021 11:47:57 +0000').valueOf(); + var date = LString('Fri, 12 Feb 2021 10:31:11 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13049,7 +13049,7 @@ var _build = [_year, _format(_date.getMonth() + 1), _format(_date.getDate())].join('-'); - var banner = "\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.11 (".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 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/, ''); return banner; }(); // ------------------------------------------------------------------------- // to be used with string function when code is minified @@ -13072,9 +13072,9 @@ LString.__class__ = 'string'; // ------------------------------------------------------------------------- var lips = { - version: '1.0.0-beta.11', + version: 'DEV', banner: banner, - date: 'Sun, 31 Jan 2021 11:47:57 +0000', + date: 'Fri, 12 Feb 2021 10:31:11 +0000', exec: exec, // unwrap async generator into Promise parse: compose(uniterate_async, parse), diff --git a/dist/std.min.scm b/dist/std.min.scm new file mode 100644 index 00000000..5b7545e9 --- /dev/null +++ b/dist/std.min.scm @@ -0,0 +1,685 @@ +(define (%doc string fn) (typecheck "%doc" fn "function") (typecheck "%doc" string "string") (set-obj! fn (quote __doc__) (--> string (replace #/^ +/gm ""))) fn)(define-macro (let-syntax vars . body) "(let-syntax ((name fn)) body) + + Macro works like combination of let and define-syntax. It creaates + local macros and evaluate body in context of those macros. + The macro to letrec-syntax is like letrec is to let." (quasiquote (let (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "let-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body))))(define-macro (letrec-syntax vars . body) "(letrec-syntax ((name fn)) body) + + Macro works like combination of letrec and define-syntax. It creaates + local macros and evaluate body in context of those macros." (quasiquote (letrec (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "letrec-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body))))(define-macro (define-syntax name expr . rest) "(define-syntax name expression [__doc__]) + +Macro define new hygienic macro using syntax-rules with optional documentation" (let ((expr-name (gensym "expr-name"))) (quasiquote (define (unquote name) (let (((unquote expr-name) (unquote expr))) (typecheck "define-syntax" (unquote expr-name) "syntax") (unquote expr-name)) (unquote-splicing rest)))))(define (quoted-symbol? x) "(quoted-symbol? code) + +Helper function that test if value is quoted symbol. To be used in macros +that pass literal code that is transformed by parser. + +usage: + + (define-macro (test x) + (if (quoted-symbol? x) + `',(cadr x))) + + (list 'hello (test 'world))" (and (pair? x) (eq? (car x) (quote quote)) (symbol? (cadr x)) (null? (cddr x))))(define-macro (--> expr . code) "Helper macro that simplify calling methods on objects. It work with chaining + +usage: (--> ($ \"body\") + (css \"color\" \"red\") + (on \"click\" (lambda () (display \"click\")))) + + (--> document (querySelectorAll \"div\")) + (--> (fetch \"https://jcubic.pl\") + (text) + (match #/([^<]+)<\\/title>/) + 1) + (--> document + (querySelectorAll \".cmd-prompt\") + 0 + \"innerText\") + (--> document.body + (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) (quasiquote (let* (((unquote obj) (unquote expr))) (unquote-splicing (map (lambda (code) (let ((value (gensym "value"))) (quasiquote (let* (((unquote value) (unquote (let ((name (cond ((quoted-symbol? code) (symbol->string (cadr code))) ((pair? code) (symbol->string (car code))) (#t code)))) (if (string? name) (quasiquote (. (unquote obj) (unquote-splicing (split "." name)))) (quasiquote (. (unquote obj) (unquote name)))))))) (unquote (if (and (pair? code) (not (quoted-symbol? code))) (quasiquote (set! (unquote obj) ((unquote value) (unquote-splicing (cdr code))))) (quasiquote (set! (unquote obj) (unquote value))))))))) code)) (unquote obj)))))(define-macro (define-global first . rest) "(define-global var value) +(define-global (name . args) body) + +Macro that define functions or variables in global context, so they can be used +inside let and get let variables in closure, Useful for universal macros." (if (pair? first) (let ((name (car first))) (quasiquote (--> lips.env (set (unquote (symbol->string name)) (lambda (unquote (cdr first)) (unquote-splicing rest)))))) (quasiquote (--> lips.env (set (unquote (symbol->string first)) (unquote (car rest)))))))(define-macro (globalize expr . rest) "(globalize expr) + + Macro will get the value of the expression and add each method as function to global + scope." (let* ((env (current-environment)) (obj (eval expr env)) (name (gensym "name")) (env-name (gensym "env-name")) (make-name (if (pair? rest) (let ((pre (symbol->string (car rest)))) (lambda (name) (string->symbol (concat pre name)))) string->symbol))) (quasiquote (let (((unquote name) (unquote expr))) (unquote-splicing (filter pair? (map (lambda (key) (if (and (not (match /^_/ key)) (function? (. obj key))) (let* ((args (gensym "args"))) (quasiquote (define-global ((unquote (make-name key)) unquote args) (apply (. (unquote name) (unquote key)) (unquote args))))))) (array->list (--> Object (keys obj))))))))))(define (single list) "(single list) + +Function check if argument is list with single element" (and (pair? list) (not (cdr list))))(define (iterator? x) "(iterator? x) + + Function check if value is JavaScript iterator object" (and (object? x) (procedure? (. x Symbol.iterator))))(define-macro (.. expr) "(.. foo.bar.baz) + +Macro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts))))))))(define (plain-object? x) "(plain-object? x) + +Function check if value is plain JavaScript object. Created using object macro." (and (== (--> (type x) (cmp "object")) 0) (eq? (. x (quote constructor)) Object)))(define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o) + +Function test if argumnet is JavaScript typed array (Scheme byte vector)." (instanceof TypedArray o))))(define (symbol->string s) "(symbol->string symbol) + +Function convert LIPS symbol to string." (if (symbol? s) (let ((name s.__name__)) (if (string? name) name (--> name (toString))))))(define (string->symbol string) "(string->symbol string) + +Function convert string to LIPS symbol." (and (string? string) (%as.data (new (. lips "LSymbol") string))))(define (alist->object alist) "(alist->object alist) + +Function convert alist pairs to JavaScript object." (if (pair? alist) (alist.toObject) (alist->object (new lips.Pair undefined ()))))(define (parent.frames) "(parent.frames) + +Funcion return list of environments from parent frames (lambda function calls)" (let iter ((result (quote ())) (frame (parent.frame 1))) (if (eq? frame (interaction-environment)) (cons frame result) (if (null? frame) result (let ((parent.frame (--> frame (get (quote parent.frame) (object :throwError #f))))) (if (function? parent.frame) (iter (cons frame result) (parent.frame 0)) result))))))(define-macro (wait time . expr) "(wait time . expr) + +Function return promise that will resolve with evaluating the expression after delay." (quasiquote (promise (timer (unquote time) (resolve (begin (unquote-splicing expr)))))))(define (pair-map fn seq-list) "(pair-map fn list) + +Function call fn argument for pairs in a list and return combined list with +values returned from function fn. It work like the map but take two items from list" (let iter ((seq-list seq-list) (result (quote ()))) (if (null? seq-list) result (if (and (pair? seq-list) (pair? (cdr seq-list))) (let* ((first (car seq-list)) (second (cadr seq-list)) (value (fn first second))) (if (null? value) (iter (cddr seq-list) result) (iter (cddr seq-list) (cons value result))))))))(define (object-expander readonly expr . rest) "(object-expander reaonly '(:foo (:bar 10) (:baz (1 2 3)))) + +Recursive function helper for defining LIPS code for create objects +using key like syntax." (let ((name (gensym "name")) (quot (if (null? rest) #f (car rest)))) (if (null? expr) (quasiquote (alist->object ())) (quasiquote (let (((unquote name) (alist->object (quote ())))) (unquote-splicing (pair-map (lambda (key value) (if (not (key? key)) (let ((msg (string-append (type key) " " (repr key) " is not a symbol!"))) (throw msg)) (let ((prop (key->string key))) (if (and (pair? value) (key? (car value))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote (object-expander readonly value)))) (if quot (quasiquote (set-obj! (unquote name) (unquote prop) (quote (unquote value)))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote value)))))))) expr)) (unquote (if readonly (quasiquote (Object.freeze (unquote name))))) (unquote name))))))(define-macro (object . expr) "(object :name value) + +Macro that create JavaScript object using key like syntax." (try (object-expander #f expr) (catch (e) (error e.message))))(define-macro (object-literal . expr) "(object-literal :name value) + +Macro that create JavaScript object using key like syntax. This is similar, +to object but all values are quoted. This macro is used with & object literal." (try (object-expander #t expr #t) (catch (e) (error e.message))))(define (alist->assign desc . sources) "(alist->assign alist . list-of-alists) + +Function that work like Object.assign but for LIPS alist." (for-each (lambda (source) (for-each (lambda (pair) (let* ((key (car pair)) (value (cdr pair)) (d-pair (assoc key desc))) (if (pair? d-pair) (set-cdr! d-pair value) (append! desc (list pair))))) source)) sources) desc)(define (key? symbol) "(key? symbol) + +Function check if symbol is key symbol, have colon as first character." (and (symbol? symbol) (== (--> (substring (symbol->string symbol) 0 1) (cmp ":")) 0)))(define (key->string symbol) "(key->string symbol) + +If symbol is key it convert that to string - remove colon." (if (key? symbol) (substring (symbol->string symbol) 1)))(define (%as.data obj) "(%as.data obj) + +Mark object as data to stop evaluation." (if (object? obj) (begin (set-obj! obj (quote data) #t) obj)))(define (%hidden-props obj) "(%hidden-props obj) + +Function return hidden names of an object, for ES6 class prototype +it return all methods since they are indistinguishable from hidden property +created using defineProperty." (let* ((descriptors (Object.getOwnPropertyDescriptors obj)) (names (Object.keys descriptors))) (--> names (filter (lambda (name) (let ((descriptor (. descriptors name))) (eq? descriptor.enumerable #f)))))))(define (dir obj . rest) "(dir obj) + +Function return all props on the object including those in prototype chain." (if (or (null? obj) (eq? obj Object.prototype)) () (let ((proto (if (null? rest) #f (car rest))) (names (Object.getOwnPropertyNames obj))) (if (not proto) (let ((hidden (%hidden-props obj))) (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) (append (array->list names) (dir (Object.getPrototypeOf obj) #t)))))(define (tree-map f tree) "(tree-map fn tree) + +Tree version of map. Function is invoked on every leaf." (if (pair? tree) (cons (tree-map f (car tree)) (tree-map f (cdr tree))) (f tree)))(define (native.number x) "(native.number obj) + +If argument is number it will convert to native number." (if (number? x) (value x) x))(define (value obj) "(value obj) + +Function unwrap LNumbers and convert nil value to undefined." (if (eq? obj ()) undefined (if (number? obj) ((. obj "valueOf")) obj)))(define-macro (define-formatter-rule . patterns) "(rule-pattern pattern) + +Anaphoric Macro for defining patterns for formatter. With Ahead, Pattern and * defined values." (let ((rules (gensym "rules"))) (quasiquote (let (((unquote rules) lips.Formatter.rules) (Ahead (lambda (pattern) (let ((Ahead (.. lips.Formatter.Ahead))) (new Ahead (if (string? pattern) (new RegExp pattern) pattern))))) (* (Symbol.for "*")) (Pattern (lambda (pattern flag) (new lips.Formatter.Pattern (list->array pattern) (if (null? flag) undefined flag))))) (unquote-splicing (map (lambda (pattern) (quasiquote (--> (unquote rules) (push (tree->array (tree-map native.number (unquote-splicing pattern))))))) patterns))))))(define-syntax cond (syntax-rules (=> else) ((cond (else else1 else2 ...)) (if #t (begin else1 else2 ...))) ((cond (test => receiver) more-clause ...) (let ((t test)) (cond/maybe-more t (receiver t) more-clause ...))) ((cond (generator guard => receiver) more-clause ...) (call-with-values (lambda () generator) (lambda t (cond/maybe-more (apply guard t) (apply receiver t) more-clause ...)))) ((cond (test) more-clause ...) (let ((t test)) (cond/maybe-more t t more-clause ...))) ((cond (test body1 body2 ...) more-clause ...) (cond/maybe-more test (begin body1 body2 ...) more-clause ...))) "(cond (predicate? . body) + (predicate? . body) + (else . body)) + +Macro for condition checks. For usage instead of nested ifs.")(define-syntax cond/maybe-more (syntax-rules () ((cond/maybe-more test consequent) (if test consequent)) ((cond/maybe-more test consequent clause ...) (if test consequent (cond clause ...)))) "(cond/maybe-more test consequent ...) + +Helper macro used by cond.")(define-macro (cond . list) "(cond (predicate? . body) + (predicate? . body)) +Macro for condition check. For usage instead of nested ifs." (if (pair? list) (let* ((item (car list)) (first (car item)) (forms (cdr item)) (rest (cdr list))) (quasiquote (if (unquote first) (begin (unquote-splicing forms)) (unquote (if (and (pair? rest) (or (eq? (caar rest) #t) (eq? (caar rest) (quote else)))) (quasiquote (begin (unquote-splicing (cdar rest)))) (if (not (null? rest)) (quasiquote (cond (unquote-splicing rest))))))))) ()))(define (%r re . rest) "(%r re) + +Create new regular expression from string, to not break Emacs formatting" (if (null? rest) (new RegExp re) (new RegExp re (car rest))))(define (interaction-environment) "(interaction-environment) + +Function return interaction environement equal to lips.env can be overwritten, +when creating new interpreter with lips.Interpreter." **interaction-environment**)(define (current-output-port) "(current-output-port) + +Function return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdout)))))(define (current-error-port) "(current-output-port) + +Function return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stderr)))))(define (current-input-port) "current-input-port) + +Function return default stdin port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdin)))))(define (regex? x) "(regex? x) + +Function return true of value is regular expression, it return false otherwise." (== (--> (type x) (cmp "regex")) 0))(define (set-repr! type fn) "(add-repr! type fn) + +Function add string represention to the type, which should be constructor function. + +Function fn should have args (obj q) and it should return string, obj is vlaue that +need to be converted to string, if the object is nested and you need to use `repr`, +it should pass second parameter q to repr, so string will be quoted when it's true. + +e.g.: (lambda (obj q) (string-append \"<\" (repr obj q) \">\"))" (typecheck "add-repr!" type "function") (typecheck "add-repr!" fn "function") (ignore (--> lips.repr (set type fn))))(define (unset-repr! type) "(unset-repr! type) + +Function remove string represention to the type, which should be constructor function, +added by add-repr! function." (typecheck "unset-repr!" type "function") (ignore (--> lips.repr (delete type))))(set-special! "&" (quote object-literal) lips.specials.SPLICE)(set-repr! Object (lambda (x q) (concat "&(" (--> (Object.getOwnPropertyNames x) (map (lambda (key) (concat ":" key " " (repr (. x key) q)))) (join " ")) ")")))(define (bound? x . rest) "(bound? x [env]) + +Function check if variable is defined in given environement or interaction environment +if not specified." (let ((env (if (null? rest) (interaction-environment) (car rest)))) (try (begin (--> env (get x)) #t) (catch (e) #f))))(define (environment-bound? env x) "(environment-bound? env symbol) + +Function check if symbol is bound variable similar to bound?." (typecheck "environment-bound?" env "environment" 1) (typecheck "environment-bound?" x "symbol" 2) (bound? x env))(define (qsort e predicate) "(qsort list predicate) + +Sort the list using quick sort alorithm according to predicate." (if (or (null? e) (<= (length e) 1)) e (let loop ((left ()) (right ()) (pivot (car e)) (rest (cdr e))) (if (null? rest) (append (append (qsort left predicate) (list pivot)) (qsort right predicate)) (if (predicate (car rest) pivot) (loop (append left (list (car rest))) right pivot (cdr rest)) (loop left (append right (list (car rest))) pivot (cdr rest)))))))(define (sort list . rest) "(sort list [predicate]) + +Sort the list using optional predicate function. if not function is specified +it will use <= and sort in increasing order." (let ((predicate (if (null? rest) <= (car rest)))) (typecheck "sort" list "pair") (typecheck "sort" predicate "function") (qsort list predicate)))(define (every fn list) "(every fn list) + +Function call function fn on each item of the list, if every value is true +it will return true otherwise it return false." (if (null? list) #t (and (fn (car list)) (every fn (cdr list)))))(define (zip . args) "(zip list1 list2 ...) + +Create one list by taking each element of each list." (if (null? args) () (if (some null? args) () (cons (map car args) (apply zip (map cdr args))))))(define-macro (promise . body) "(promise . body) + +Anaphoric macro that expose resolve and reject functions from JS promise" (quasiquote (new Promise (lambda (resolve reject) (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message))))))))(define-macro (timer time . body) "(timer time . body) + +Macro evaluate expression after delay, it return timer. To clear the timer you can use +native JS clearTimeout function." (quasiquote (setTimeout (lambda () (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message))))) (unquote time))))(define (defmacro? obj) "(defmacro? expression) + +Function check if object is macro and it's expandable." (and (macro? obj) (. obj (quote defmacro))))(define (n-ary n fn) "(n-ary n fn) + +Return new function that limit number of arguments to n." (lambda args (apply fn (take n args))))(define (take n lst) "(take n list) + +Return n first values of the list." (let iter ((result (quote ())) (i n) (lst lst)) (if (or (null? lst) (<= i 0)) (reverse result) (iter (cons (car lst) result) (- i 1) (cdr lst)))))(define unary (%doc "(unary fn) + +Function return new function with arguments limited to one." (curry n-ary 1)))(define binary (%doc "(binary fn) + +Function return new function with arguments limited to two." (curry n-ary 2)))(define (%class-lambda expr) "(class-lambda expr) + +Return lambda expression where input expression lambda have `this` as first argument." (let ((args (gensym (quote args)))) (quasiquote (lambda (unquote args) (apply (unquote (cadr expr)) this (unquote args))))))(define (%class-lambda expr) "(%class-lambda expr) + +Define lambda that have self is first argument. The expr is in a form: +(constructor (lambda (self ...) . body)) as given by define-class macro." (let ((args (cdadadr expr))) (quasiquote (lambda ((unquote-splicing args)) ((unquote (cadr expr)) this (unquote-splicing args))))))(define (%class-method-name expr) "(%class-method-name expr) + +Helper function that allow to use [Symbol.asyncIterator] inside method name." (if (pair? expr) (car expr) (list (quote quote) expr)))(define-macro (define-class name parent . body) "(define-class name parent . body) + +Define class - JavaScript function constructor with prototype. + +usage: + + (define-class Person Object + (constructor (lambda (self name) + (set-obj! self '_name name))) + (hi (lambda (self) + (display (string-append self._name \" say hi\")) + (newline)))) + (define jack (new Person \"Jack\")) + (jack.hi)" (let iter ((functions (quote ())) (constructor (quote ())) (lst body)) (if (null? lst) (quasiquote (begin (define (unquote name) (unquote (if (null? constructor) (quasiquote (lambda ())) (%class-lambda constructor)))) (set-obj! (unquote name) (Symbol.for "__class__") #t) (unquote (if (and (not (null? parent)) (not (eq? parent (quote Object)))) (quasiquote (begin (set-obj! (unquote name) (quote prototype) (Object.create (. (unquote parent) (quote prototype)))) (set-obj! (. (unquote name) (quote prototype)) (quote constructor) (unquote name)))))) (unquote-splicing (map (lambda (fn) (quasiquote (set-obj! (. (unquote name) (quote prototype)) (unquote (%class-method-name (car fn))) (unquote (%class-lambda fn))))) functions)))) (let ((item (car lst))) (if (eq? (car item) (quote constructor)) (iter functions item (cdr lst)) (iter (cons item functions) constructor (cdr lst)))))))(define-syntax class (syntax-rules () ((_) (error "class: parent required")) ((_ parent body ...) (let () (define-class temp parent body ...) temp))) "(class <parent> body ...) + +Macro allow to create anonymous classes. See define-class for details.")(define (make-tags expr) "(make-tags expression) + +Function that return list structure of code with better syntax then raw LIPS" (quasiquote (h (unquote (let ((val (car expr))) (if (key? val) (key->string val) val))) (alist->object ((unquote (quote quasiquote)) (unquote (pair-map (lambda (car cdr) (quasiquote ((unquote (key->string car)) (unquote (quote unquote)) (unquote cdr)))) (cadr expr))))) (unquote (if (not (null? (cddr expr))) (if (and (pair? (caddr expr)) (let ((s (caaddr expr))) (and (symbol? s) (eq? s (quote list))))) (quasiquote (list->array (list (unquote-splicing (map make-tags (cdaddr expr)))))) (caddr expr)))))))(define (%sxml h expr) "(%sxml h expr) + +Helper function that render expression using create element function." (let* ((have-attrs (and (not (null? (cdr expr))) (pair? (cadr expr)) (eq? (caadr expr) (quote @)))) (attrs (if have-attrs (cdadr expr) ())) (rest (if have-attrs (cddr expr) (cdr expr)))) (quasiquote ((unquote h) (unquote (let* ((symbol (car expr)) (name (symbol->string symbol))) (if (char-lower-case? (car (string->list name))) name symbol))) (alist->object ((unquote (quote quasiquote)) (unquote (map (lambda (pair) (cons (symbol->string (car pair)) (list (quote unquote) (cadr pair)))) attrs)))) (unquote-splicing (if (null? rest) () (let ((first (car rest))) (if (pair? first) (map (lambda (expr) (%sxml h expr)) rest) (list first)))))))))(define-macro (sxml expr) "(sxml expr) + +Macro for JSX like syntax but with SXML. +e.g. usage: + +(sxml (div (@ (data-foo \"hello\") + (id \"foo\")) + (span \"hello\") + (span \"world\")))" (%sxml (quote h) expr))(define-macro (with-tags expr) "(with-tags expression) + +Macro that evalute LIPS shorter code for S-Expression equivalent of JSX. +e.g.: + +(with-tags (:div (:class \"item\" :id \"item-1\") + (list (:span () \"Random Item\") + (:a (:onclick (lambda (e) (alert \"close\"))) + \"close\")))) + +Above expression can be passed to function that renders JSX (like render in React, Preact) +To get the string from the macro you can use vhtml library from npm." (make-tags expr))(define (get-script url) "(get-script url) + +Load JavaScript file in browser by adding script tag to head of the current document." (if (not (bound? (quote document))) (throw (new Error "get-script: document not defined")) (let ((script (document.createElement "script"))) (new Promise (lambda (resolve reject) (set-obj! script (quote src) url) (set-obj! script (quote onload) (lambda () (resolve))) (set-obj! script (quote onerror) (lambda () (reject "get-script: Failed to load"))) (if document.head (document.head.appendChild script)))))))(define (gensym? value) "(gensym? value) + +Function return #t if value is symbol and it's gensym. It returns #f otherwise." (and (symbol? value) (--> value (is_gensym))))(define (degree->radians x) "(degree->radians x) + +Convert degree to radians." (* x (/ Math.PI 180)))(define (radians->degree x) "(radians->degree x) + +Convert radians to degree." (* x (/ 180 Math.PI)))(define-syntax while (syntax-rules () ((_ predicate body ...) (do () ((not predicate)) body ...))) "(while cond . body) + +Macro that create a loop, it exectue body until cond expression is false.")(define-syntax ++ (syntax-rules () ((++ x) (let ((tmp (+ x 1))) (set! x tmp) tmp))) "(++ variable) + +Macro that work only on variables and increment the value by one.")(define-syntax -- (syntax-rules () ((-- x) (let ((tmp (- x 1))) (set! x tmp) tmp))) "(-- variable) + +Macro that decrement the value it work only on symbols")(define (pretty-format pair) "(pretty-format pair) + +Function return pretty printed string from pair expression." (typecheck "pretty-pair" pair "pair") (--> (new lips.Formatter (repr pair #t)) (break) (format)))(define (reset) "(reset) + +Function reset environment and remove all user defined variables." (let-env **interaction-environment** (let ((defaults **interaction-environment-defaults**) (env **interaction-environment**)) (--> env (list) (forEach (lambda (name) (if (not (--> defaults (includes name))) (--> env (unset name)))))))))(define (make-list n . rest) (if (or (not (integer? n)) (<= n 0)) (throw (new Error "make-list: first argument need to be integer larger then 0")) (let ((fill (if (null? rest) undefined (car rest)))) (array->list (--> (new Array n) (fill fill))))))(define (range n) "(range n) + +Function return list of n numbers from 0 to n - 1" (typecheck "range" n "number") (array->list (--> (new Array n) (fill 0) (map (lambda (_ i) i)))))(define-macro (do-iterator spec cond . body) "(do-iterator (var expr) (test) body ...) + +Macro iterate over iterators (e.g. create with JavaScript generator function) +it works with normal and async iterators. You can loop over infinite iterators +and break the loop if you want, using expression like in do macro, long sync iterators +will block main thread (you can't print 1000 numbers from inf iterators, +because it will freeze the browser), but if you use async iterators you can process +the values as they are generated." (let ((gen (gensym "name")) (name (car spec)) (async (gensym "async")) (sync (gensym "sync")) (iterator (gensym "iterator")) (test (if (null? cond) #f (car cond))) (next (gensym "next")) (stop (gensym "stop")) (item (gensym "item"))) (quasiquote (let* (((unquote gen) (unquote (cadr spec))) ((unquote sync) (. (unquote gen) Symbol.iterator)) ((unquote async) (. (unquote gen) Symbol.asyncIterator)) ((unquote iterator)) ((unquote next) (lambda () ((. (unquote iterator) "next"))))) (if (or (procedure? (unquote sync)) (procedure? (unquote async))) (begin (set! (unquote iterator) (if (procedure? (unquote sync)) ((unquote sync)) ((unquote async)))) (let* (((unquote item) ((unquote next))) ((unquote stop) #f) ((unquote name) (. (unquote item) "value"))) (while (not (or (eq? (. (unquote item) "done") #t) (unquote stop))) (if (unquote test) (set! (unquote stop) #t) (begin (unquote-splicing body))) (set! (unquote item) ((unquote next))) (set! (unquote name) (. (unquote item) "value"))))))))))(set-repr! Set (lambda () "#<Set>"))(set-repr! Map (lambda () "#<Met>"))(define (native-symbol? x) "(native-symbol? object) + +Function check if value is JavaScript symbol." (and (string=? (type x) "symbol") (not (symbol? x))))(set-special! "’" (quote warn-quote))(define-macro (warn-quote) "(warn-quote) + +Simple macro that throw error, when you try to use ’ symbol as quote in code" (throw (new Error (string-append "You're using invalid quote character run: " "(set-special! \"’\" 'quote)" " to allow running this type of quote"))))(define-macro (quote-promise expr) "(quote-promise expr) +'>expr + +Macro used to escape promise the whole expression, will be wrapped +with JavaScript class that behave like Promise but will not +auto resolve like normal promise." (quasiquote (let ((env)) (set! env (current-environment)) (env.set (Symbol.for "__promise__") #t) (unquote expr))))(define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value))(define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body) + +Macro add mapping for variables var from specified env, +Macro work similar to let-env but lexical scope is working with it." (let ((env-name (gensym (quote env)))) (quasiquote (let (((unquote env-name) (unquote env))) (let (unquote (map (lambda (pair) (quasiquote ((unquote (car pair)) (--> (unquote env-name) (get (quote (unquote (cadr pair)))))))) spec)) (unquote-splicing body))))))(define-macro (let-std spec . body) "(let-std ((name var)) . body) + +Macro that create aliases for variables in global environment. +This is needed so user don't change constants like stdin or stdout +that use taken from lexical scope. The function still can use those +from interaction-environment." (quasiquote (let-env-values lips.env.__parent__ (unquote spec) (unquote-splicing body))))(define (apropos name) "(apropos name) + +Search environment and display names that match the given name. +name can be regex or string." (typecheck "apropos" name (quote ("string" "regex"))) (filter (if (string? name) (new RegExp name) name) (env)))(set-special! "#," (quote sharp-comma))(define **reader-ctor-list** (quote ()))(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**)))))(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...))))))))))(define (promisify fn) "(promisify fn) + +Simple function for adding promises to NodeJS callback based function. +Function tested only with fs module." (lambda args (new Promise (lambda (resolve reject) (apply fn (append args (list (lambda (err data) (if (null? err) (resolve data) (reject err))))))))))(define-macro (list* . args) "(list* arg1 ...) + +Parallel version of list." (let ((result (gensym "result"))) (quasiquote (let (((unquote result) (vector))) (unquote-splicing (map (lambda (arg) (quasiquote (--> (unquote result) (push (quote-promise (unquote arg)))))) args)) (map await (vector->list (unquote result)))))))(define-macro (%not-implemented name) "(not-implemented name) + +Returns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ") + +This function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented"))))))))(define-macro (%make-env name . names) "(%make-env name f1 f2 ...) + +Create new Environment with given name and defined symbols in it from global env. +If given function name f1 f2 ... don't exists, it will define function that +throw exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name))))(define Y (lambda (h) "(Y f) + + _ __ __ _ _ _ _ __ __ _ _ _ + / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\ ++ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + + +| \\ / | \\ \\ | | |__ | | \\ / | |__ | | | +| | | | / \\ | | __| | | | | | __| | | | +| | | | / /\\ \\ | | | | | | | | | | | | ++ |_| + /_/ \\_\\ + |_| + + |_| |_| + + + + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) + +Macro that creates special symbol macro for evaluator similar to build in , or `. +It's like alias for real macro. Similar to CL reader macros but it receive already +parsed code like normal macros. Type can be SPLICE or LITERAL symbols. +ALL default symbol macros are literal." (let* ((name (car spec)) (symbol (cadr spec)) (args (cddr spec))) (quasiquote (begin (set-special! (unquote symbol) (quote (unquote name)) (unquote (string->symbol (concat "lips.specials." (symbol->string type))))) (define-macro ((unquote name) (unquote-splicing args)) (unquote-splicing rest))))))(set-special! "#" (quote vector-literal) lips.specials.SPLICE)(define-macro (vector-literal . args) (if (not (or (pair? args) (eq? args ()))) (throw (new Error (concat "Parse Error: vector require pair got " (type args) " in " (repr args)))) (let ((v (list->array args))) (Object.freeze v) v)))(define-syntax vector (syntax-rules () ((_ arg ...) (list->array (list arg ...)))) "(vector 1 2 3 (+ 3 1)) +#(1 2 3 4) + +Macro for defining vectors (JavaScript arrays). Vectors literals are +automatically quoted. So you can use expressions inside them. Only other +literals, like other vectors or object.")(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")"))))(define (eqv? a b) "(eqv? a b) + +Function compare the values. It return true if they are the same, they +need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (= a b)) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) + +Function check if values are equal if both are pair or array +it compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b))))(define make-promise (lambda (proc) "(make-promise fn) + +Function create promise from a function." (typecheck "make-promise" proc "function") (let ((result-ready? #f) (result #f)) (let ((promise (lambda () (if result-ready? result (let ((x (proc))) (if result-ready? result (begin (set! result-ready? #t) (set! result x) result))))))) (set-obj! promise (Symbol.for "promise") #t) (set! promise.toString (lambda () (string-append "#<promise - " (if result-ready? (string-append "forced with " (type result)) "not forced") ">"))) promise))))(define-macro (delay expression) "(delay expression) + +Macro will create a promise from expression that can be forced with (force)." (quasiquote (make-promise (lambda () (unquote expression)))))(define (force promise) "(force promise) + +Function force the promise and evaluate delayed expression." (promise))(define (promise? obj) "(promise? obj) + +Function check if value is a promise created with delay or make-promise." (string=? (type obj) "promise"))(define (positive? x) "(positive? x) + +Function check if number is larger then 0" (typecheck "positive?" x "number") (> x 0))(define (negative? x) "(negative? x) + +Function check if number is smaller then 0" (typecheck "negative?" x "number") (< x 0))(define (zero? x) "(zero? x) + +Function check if number is equal to 0" (typecheck "zero?" x "number") (= x 0))(define (quotient a b) "(quotient a b) + +Return quotient from divition as integer." (typecheck "quotient" a "number") (typecheck "quotient" b "number") (if (zero? b 0) (throw (new Error "quotient: divition by zero")) (let ((quotient (/ a b))) (if (integer? quotient) quotient (if (> quotient 0) (floor quotient) (ceiling quotient))))))(define (number->string x . rest) "(number->string x [radix]) + +Function convert number to string with optional radix (number base)." (typecheck "number->string" x "number" 1) (let ((radix (if (null? rest) 10 (car rest)))) (typecheck "number->string" radix "number" 2) (--> x (toString (--> radix (valueOf))))))(define (boolean? x) "(boolean? x) + +Function return true if value is boolean." (string=? (type x) "boolean"))(define (vector-ref vector i) "(vector-ref vector i) + +Return i element from vector." (typecheck "number->string" vector "array" 1) (typecheck "number->string" i "number" 2) (. vector i))(define (vector-set! vector i obj) "(vector-set! vector i obj) + +Set obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj))(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type)))))(define integer? (%doc "" (curry %number-type "bigint")))(define complex? (%doc "" (curry %number-type "complex")))(define rational? (%doc "" (curry %number-type (quote ("rational" "bigint")))))(define (typecheck-args _type name _list) "(typecheck-args args type) + +Function check if all items in array are of same type." (let iter ((n 1) (_list _list)) (if (pair? _list) (begin (typecheck name (car _list) _type n) (iter (+ n 1) (cdr _list))))))(define numbers? (curry typecheck-args "number"))(define (max . args) "(max n1 n2 ...) + +Return maximum of it's arguments." (numbers? "max" args) (apply (.. Math.max) args))(define (min . args) "(min n1 n2 ...) + +Return minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) args))(define (make-rectangular re im) "(make-rectangular im re) + +Create complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t)))))(define (real? n) "(real? n)" (and (number? n) (let ((type n.__type__)) (or (string=? type "float") (string=? type "bigint")))))(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__)))))(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n)))(define (exact->inexact n) "(exact->inexact n) + +Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (complex? n) (lips.LComplex (object :im (. n (quote im)) :re (. n (quote re)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) + +Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (complex? n)) (--> n (toRational)) n))(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan"))(define _this_env (current-environment))(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n) + +Function calculate " name " math operation (it call JavaScript Math)." name " function.")) (iter (cdr fns)))))(define (modulo a b) "(modulo a b) + +Function return modulo operation on it's argumennts." (typecheck "modulo" a "number" 1) (typecheck "modulo" b "number" 2) (- a (* b (floor (/ a b)))))(define (remainder__ a b) "(modulo a b) + +Function return reminder from division operation." (typecheck "remainder" a "number" 1) (typecheck "remainder" b "number" 2) (- a (* b (truncate (/ a b)))))(define (list-tail l k) "(list-tail list k) + +Returns the sublist of list obtained by omitting the first k elements." (typecheck "list-tail" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-tail: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) l)))(define (list-ref l k) "(list-ref list n) + +Returns n element of a list." (typecheck "list-ref" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l)))))(define (not x) "(not x) + +Function return true if value is false and false otherwise." (if x #f #t))(define (rationalize number tolerance) "(rationalize number tolerance) + +Function returns simplest rational number differing from number by no more +than the tolerance." (typecheck "rationalize" number "number" 1) (typecheck "rationalize" tolerance "number" 2) (lips.rationalize number tolerance))(define (%mem/search access op obj list) "(%member obj list function) + +Helper method to get first list where car equal to obj +using provied functions as comparator." (if (null? list) #f (if (op (access list) obj) list (%mem/search access op obj (cdr list)))))(define (memq obj list) "(memq obj list) + +Function return first object in the list that match using eq? function." (typecheck "memq" list (quote ("nil" "pair"))) (%mem/search car eq? obj list))(define (memv obj list) "(memv obj list) + +Function return first object in the list that match using eqv? function." (typecheck "memv" list (quote ("nil" "pair"))) (%mem/search car eqv? obj list))(define (member obj list) "(member obj list) + +Function return first object in the list that match using equal? function." (typecheck "member" list (quote ("nil" "pair"))) (%mem/search car equal? obj list))(define (%assoc/acessor name) "(%assoc/acessor name) + +Function return carr with typecheck using give name." (lambda (x) (typecheck name x "pair") (caar x)))(define (%assoc/search op obj alist) "(%assoc/search op obj alist) + +Generic function that used in assoc functions with defined comparator +function." (typecheck "assoc" alist (vector "nil" "pair")) (let ((ret (%mem/search (%assoc/acessor "assoc") op obj alist))) (if ret (car ret) ret)))(define assoc (%doc "(assoc obj alist) + +Function return pair from alist that match given key using equal? check." (curry %assoc/search equal?)))(define assq (%doc "(assq obj alist) + +Function return pair from alist that match given key using eq? check." (curry %assoc/search eq?)))(define assv (%doc "(assv obj alist) + +Function return pair from alist that match given key using eqv? check." (curry %assoc/search eqv?)))(define (make-string k . rest) "(make-string k [char]) + +Function return new string with k elements, if char is provied +it's filled with that character." (let ((char (if (null? rest) #\space (car rest)))) (typecheck "make-string" k "number" 1) (typecheck "make-string" char "character" 2) (let iter ((result (quote ())) (k k)) (if (<= k 0) (list->string result) (iter (cons char result) (- k 1))))))(define (string . args) "(string chr1 chr2 ...) + +Function create new string from it's arguments. Each argument +Need to be a character object." (for-each (lambda (x) (typecheck "string" x "character")) args) (list->string args))(define (string-copy string) "(string-copy string) + +Returns a copy of the given string." (typecheck "string-copy" string "string") (--> string (clone)))(define (string-fill! string char) "(string-fill! symbol char) + +Function destructively fill the string with given character." (typecheck "string-fill!" string "string" 1) (typecheck "string-fill!" char "character" 2) (--> string (fill char)))(define (identity n) "(identity n) + +No op function. it just returns its argument." n)(define (string-copy x) "(string-copy x) + +Create new string based of given argument." (typecheck "string-copy" x "string") (lips.LString x))(define (list->string _list) "(list->string _list) + +Function return string from list of characters." (let ((array (list->array (map (lambda (x) (typecheck "list->string" x "character") (x.valueOf)) _list)))) (--> array (join ""))))(define (string->list string) "(string->list string) + +Function return list of characters created from string." (typecheck "string->list" string "string") (array->list (--> string (split "") (map (lambda (x) (lips.LCharacter x))))))(define-macro (string-set! object index char) "(string-set! object index char) + +Macro that replace character in string in given index, it create new JavaScript +string and replace old value. Object need to be symbol that point to variable +that hold the string." (typecheck "string-set!" object "symbol") (let ((chars (gensym "chars"))) (quasiquote (begin (typecheck "string-set!" (unquote object) "string") (typecheck "string-set!" (unquote index) "number") (typecheck "string-set!" (unquote char) "character") (let (((unquote chars) (list->vector (string->list (unquote object))))) (set-obj! (unquote chars) (unquote index) (unquote char)) (set! (unquote object) (list->string (vector->list (unquote chars)))))))))(define (string-length string) "(string-length string) + +Function return length of the string." (typecheck "string-ref" string "string") (. string (quote length)))(define (string-ref string k) "(string-ref string k) + +Function return character inside string at given zero-based index." (typecheck "string-ref" string "string" 1) (typecheck "string-ref" k "number" 2) (lips.LCharacter (--> string (get k))))(define (%string-cmp name string1 string2) "(%string-cmp name a b) + +Function compare two strings and return 0 if they are equal, +-1 second is smaller and 1 if is larget. The function compare +the codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (cmp string2)))(define (string=? string1 string2) "(string=? string1 string2) + +Function check if two string s are equal." (= (%string-cmp "string=?" string1 string2) 0))(define (string<? string1 string2) "(string<? string1 string2) + +Function return true if second string is smaller then the first one." (= (%string-cmp "string<?" string1 string2) -1))(define (string>? string1 string2) "(string<? string1 string2) + +Function return true if second string is larger then the first one." (= (%string-cmp "string>?" string1 string2) 1))(define (string<=? string1 string2) "(string<? string1 string2) + +Function return true if second string is not larger then the first one." (< (%string-cmp "string<=?" string1 string2) 1))(define (string>=? string1 string2) "(string<? string1 string2) + +Function return true if second character is not smaller then the first one." (> (%string-cmp "string>=?" string1 string2) -1))(define (%string-ci-cmp name string1 string2) "(%string-ci-cmp name a b) + +Function compare two strings ingoring case and return 0 if they are equal, +-1 second is smaller and 1 if is larget. The function compare +the codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (lower) (cmp (--> string2 (lower)))))(define (string-ci=? string1 string2) "(string-ci=? string1 string2) + +Function check if two string s are equal." (= (%string-ci-cmp "string-ci=?" string1 string2) 0))(define (string-ci<? string1 string2) "(string-ci<? string1 string2) + +Function return true if second string is smaller then the first one." (= (%string-ci-cmp "string-ci<?" string1 string2) -1))(define (string-ci>? string1 string2) "(string-ci<? string1 string2) + +Function return true if second string is larger then the first one." (= (%string-ci-cmp "string-ci>?" string1 string2) 1))(define (string-ci<=? string1 string2) "(string-ci<? string1 string2) + +Function return true if second string is not larger then the first one." (< (%string-ci-cmp "string-ci<=?" string1 string2) 1))(define (string-ci>=? string1 string2) "(string-ci>=? string1 string2) + +Function return true if second character is not smaller then the first one." (> (%string-ci-cmp "string-ci>=?" string1 string2) -1))(define char? (%doc "(char? obj) + +Function check if object is character." (curry instanceof lips.LCharacter)))(define (char->integer chr) "(char->integer chr) + +Function return codepoint of Unicode character." (typecheck "char->integer" chr "character") (--> chr.__char__ (codePointAt 0)))(define (integer->char n) "(integer->char chr) + +Function convert number argument to chararacter." (typecheck "integer->char" n "number") (if (integer? n) (string-ref (String.fromCodePoint n) 0) (throw "argument to integer->char need to be integer.")))(define-macro (%define-chr-re spec str re) "(%define-chr-re (name chr) sring re) + +Macro define procedure that test character agains regular expression." (quasiquote (define (unquote spec) (unquote str) (typecheck (unquote (symbol->string (car spec))) (unquote (cadr spec)) "character") (not (null? (--> chr (toString) (match (unquote re))))))))(%define-chr-re (char-whitespace? chr) "(char-whitespace? chr) + +Function return true if character is whitespace." (let-env (interaction-environment) (--> **internal-env** (get (quote space-unicode-regex)))))(%define-chr-re (char-numeric? chr) "(char-numeric? chr) + +Function return true if character is number." (let-env (interaction-environment) (--> **internal-env** (get (quote numeral-unicode-regex)))))(%define-chr-re (char-alphabetic? chr) "(char-alphabetic? chr) + +Function return true if character is leter of the ASCII alphabet." (let-env (interaction-environment) (--> **internal-env** (get (quote letter-unicode-regex)))))(define (%char-cmp name chr1 chr2) "(%char-cmp name a b) + +Function compare two characters and return 0 if they are equal, +-1 second is smaller and 1 if is larget. The function compare +the codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (let ((a (char->integer chr1)) (b (char->integer chr2))) (cond ((= a b) 0) ((< a b) -1) (else 1))))(define (char=? chr1 chr2) "(char=? chr1 chr2) + +Function check if two characters are equal." (= (%char-cmp "char=?" chr1 chr2) 0))(define (char<? chr1 chr2) "(char<? chr1 chr2) + +Function return true if second character is smaller then the first one." (= (%char-cmp "char<?" chr1 chr2) -1))(define (char>? chr1 chr2) "(char<? chr1 chr2) + +Function return true if second character is larger then the first one." (= (%char-cmp "char>?" chr1 chr2) 1))(define (char<=? chr1 chr2) "(char<? chr1 chr2) + +Function return true if second character is not larger then the first one." (< (%char-cmp "char<=?" chr1 chr2) 1))(define (char>=? chr1 chr2) "(char<? chr1 chr2) + +Function return true if second character is not smaller then the first one." (> (%char-cmp "char>=?" chr1 chr2) -1))(define (%char-ci-cmp name chr1 chr2) "(%char-cmp name a b) + +Function compare two characters and return 0 if they are equal, +-1 second is smaller and 1 if is larget. The function compare +the codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (%char-cmp name (char-downcase chr1) (char-downcase chr2)))(define (char-ci=? chr1 chr2) "(char-ci=? chr1 chr2) + +Function check if two characters are equal." (= (%char-ci-cmp "char-ci=?" chr1 chr2) 0))(define (char-ci<? chr1 chr2) "(char-ci<? chr1 chr2) + +Function return true if second character is smaller then the first one." (= (%char-ci-cmp "char-ci<?" chr1 chr2) -1))(define (char-ci>? chr1 chr2) "(char-ci<? chr1 chr2) + +Function return true if second character is larger then the first one." (= (%char-ci-cmp "char-ci>?" chr1 chr2) 1))(define (char-ci<=? chr1 chr2) "(char-ci<? chr1 chr2) + +Function return true if second character is not larger then the first one." (< (%char-ci-cmp "char-ci<=?" chr1 chr2) 1))(define (char-ci>=? chr1 chr2) "(char-ci<? chr1 chr2) + +Function return true if second character is not smaller then the first one." (> (%char-ci-cmp "char-ci>=?" chr1 chr2) -1))(define (char-upcase char) "(char-upcase char) + +Create uppercase version of the character." (typecheck "char-upcase" char "character") (char.toUpperCase))(define (char-downcase char) "(char-downcase chr) + +Create lowercase version of the character." (typecheck "char-upcase" char "character") (char.toLowerCase))(define (char-upper-case? char) "(char-upper-case? char) + +Function check if character is upper case." (typecheck "char-upper-case?" char "character") (and (char-alphabetic? char) (char=? (char-upcase char) char)))(define (char-lower-case? char) "(char-upper-case? char) + +Function check if character is lower case." (typecheck "char-lower-case?" char "character") (and (char-alphabetic? char) (char=? (char-downcase char) char)))(define (newline . rest) "(newline [port]) + +Write newline character to standard output or given port" (let ((port (if (null? rest) (current-output-port) (car rest)))) (display " +" port)))(define (write obj . rest) "(write obj [port]) + +Write object to standard output or give port. For strings it will include +wrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (display (repr obj #t) port)))(define (write-char char . rest) "(write-char char [port]) + +Write single character to given port using write function." (typecheck "write-char" char "character") (apply display (cons (char.valueOf) rest)))(define fold-right reduce)(define fold-left fold)(define (make-vector n . rest) "(make-vector n [fill]) + +Create new vector with n empty elements. If fill is specified it will set +all elements of the vector to that value." (let ((result (new Array n))) (if (not (null? rest)) (--> result (fill (car rest))) result)))(define (vector? n) "(vector? n) + +Function return true of value is vector and false if not." (string=? (type n) "array"))(define (vector-ref vec n) "(vector-ref vec n) + +Function return nth element of the vector vec." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (. vec n))(define (vector-set! vec n value) "(vector-set! vec n value) + +Function set nth item of the vector to value." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (set-obj! vec n value))(define (vector-fill! vec value) "(vector-fill! vec value) + +Set every element of the vector to given value." (typecheck "vector-ref" vec "array") (let recur ((n (- (length vec) 1))) (if (>= n 0) (begin (set-obj! vec n value) (recur (- n 1))))))(define (vector-length vec) "(vector-length vec) + +Function return length of the vector. If argument is not vector it throw exception." (typecheck "vector-length" vec "array") (length vec))(define-syntax case (syntax-rules (else =>) ((case (key ...) clauses ...) (let ((atom-key (key ...))) (case atom-key clauses ...))) ((case key (else => result)) (result key)) ((case key (else result1 result2 ...)) (begin result1 result2 ...)) ((case key ((atoms ...) result1 result2 ...)) (if (memv key (quote (atoms ...))) (begin result1 result2 ...))) ((case key ((atoms ...) => result)) (if (memv key (quote (atoms ...))) (result key))) ((case key ((atoms ...) => result) clause clauses ...) (if (memv key (quote (atoms ...))) (result key) (case key clause clauses ...))) ((case key ((atoms ...) result1 result2 ...) clause clauses ...) (if (memv key (quote (atoms ...))) (begin result1 result2 ...) (case key clause clauses ...)))) "(case value + ((<items>) result1) + ((<items>) result2) + [else result3]) + +Macro for switch case statement. It test if value is any of the item. If +item match the value it will return coresponding result expression value. +If no value match and there is else it will return that result.")(--> lips.Formatter.defaults.exceptions.specials (push "case"))(define (numerator n) "(numerator n) + +Return numberator of rational or same number if n is not rational." (typecheck "numerator" n "number") (if (and (rational? n) (not (integer? n))) n.num n))(define (denominator n) "(denominator n) + +Return denominator of rational or same number if one is not rational." (typecheck "denominator" n "number") (if (and (rational? n) (not (integer? n))) n.denom (if (exact? n) 1 1.0)))(define (imag-part n) "(imag-part n) + +Return imaginary part of the complex number n." (typecheck "imag-part" n "number") (if (complex? n) n.__im__ 0))(define (real-part n) "(real-part n) + +Return real part of the complex number n." (typecheck "real-part" n "number") (if (complex? n) n.re n))(define (make-polar r angle) "(make-polar magnitude angle) + +Create new complex number from polar parameters." (typecheck "make-polar" r "number") (typecheck "make-polar" angle "number") (if (or (complex? r) (complex? angle)) (error "make-polar: argument can't be complex") (let ((re (* r (sin angle))) (im (* r (cos angle)))) (make-rectangular im re))))(define (angle x) "(angle x) + +Returns angle of the complex number in polar coordinate system." (if (not (complex? x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__)))(define (magnitude x) "(magnitude x) + +Returns magnitude of the complex number in polar coordinate system." (if (not (complex? x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__)))))(define random (let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110)) (lambda new-seed "(random) +(random seed) + +Function generate new random real number using Knuth algorithm." (if (pair? new-seed) (set! seed (car new-seed)) (set! seed (modulo (+ (* seed a) c) m))) (exact->inexact (/ seed m)))))(define (eof-object? obj) "(eof-object? arg) + +Function check if value is eof object, returned from input string +port when there are no more data to read." (eq? obj eof))(define (output-port? obj) "(output-port? arg) + +Function return true if argument is output port." (instanceof lips.OutputPort obj))(define (input-port? obj) "(input-port? arg) + +Function return true if argument is input port." (instanceof lips.InputPort obj))(define (char-ready? . rest) "(char-ready?) +(char-ready? port) + +Function check it characters is ready in input port. This is usefull mostly +for interactive ports that return false if it would wait for user input. +It return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready)))(if (eq? global self) (set! self.fs (require "fs")))(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename) + +Function return new Input Port with given filename. In Browser user need to +provide global fs variable that is instance of FS interface." (if (null? self.fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) "(readFile filename) + +Helper function that return Promise. NodeJS function sometimes give warnings +when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename))))))(define (close-input-port port) "(close-input-port port) + +Procedure close port that was opened with open-input-file. After that +it no longer accept reading from that port." (typecheck "close-input-port" port "input-port") (port.close))(define (close-output-port port) "(close-output-port port) + +Procedure close port that was opened with open-output-file. After that +it no longer accept write to that port." (typecheck "close-output-port" port "output-port") (port.close))(define (call-with-input-file filename proc) "(call-with-input-file filename proc) + +Procedure open file for reading, call user defined procedure with given port +and then close the port. It return value that was returned by user proc +and it close the port even if user proc throw exception." (let ((p (open-input-file filename))) (try (proc p) (finally (close-input-port p)))))(define (call-with-output-file filename proc) "(call-with-output-file filename proc) + +Procedure open file for writing, call user defined procedure with port +and then close the port. It return value that was returned by user proc and it close the port +even if user proc throw exception." (let ((p (open-output-file filename))) (try (proc p) (finally (close-output-port p)))))(define (with-input-from-file string thunk) "(with-input-from-file string thunk) + +Procedure open file and make it current-input-port then thunk is executed. +After thunk is executed current-input-port is restored and file port +is closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port)))))(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port)))))(define (file-exists? filename) (new Promise (lambda (resolve) (if (null? self.fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename) + +Function open file and return port that can be used for writing. If file +exists it will throw an Error." (typecheck "open-output-file" filename "string") (if (null? self.fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))(define (scheme-report-environment version) (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported"))))))(define-macro (%make-vector prefix type help) "(%make-vector prefix type help) + +Mega helper macro that create list of functions for single byte vector +based on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...) + +Create ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v) + +return length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a v1 v2 ...) + +Allocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x) + +Function return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k) + +Function test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k) + +Function return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k) + +Function set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote))))))))(%make-vector u8 Uint8Array "usigned 8-bit integer vector")(%make-vector s8 Int8Array "signed 8-bit integer vector")(%make-vector u16 Uint16Array "usigned 16-bit integer vector")(%make-vector s16 Int16Array "signed 16-bit integer vector")(%make-vector u32 Uint16Array "usigned 32-bit integer vector")(%make-vector s32 Int16Array "signed 32-bit integer vector")(%make-vector f32 Float32Array "32-bit IEEE floating point number vector")(%make-vector f64 Float64Array "64-bit IEEE floating point number vector")(define (list-match? predicate list) "(list-match? predicate list) + +Function check if consecutive elements of the list match the predicate function." (typecheck "list-match?" predicate #("function" "macro")) (typecheck "list-match?" list "pair") (or (or (null? list) (null? (cdr list))) (and (predicate (car list) (cadr list)) (list-match? predicate (cdr list)))))(define (symbol=? . args) "(symbol=? s1 s2 ...) + +Function check if each value is symbol and it's the same acording to string=? predicate." (list-match? (lambda (a b) (and (symbol? a) (symbol? b) (equal? a b))) args))(define (values-ref values n) "(values-ref values n) + +Function return n value of values object which is result of value function." (typecheck "values-ref" values "values" 1) (typecheck "values-ref" n "number" 1) (--> values (valueOf) n))(define-syntax let-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ (((x ...) values) ...) body ...) (apply (lambda (x ... ...) body ...) (vector->list (apply vector-append (map (lambda (x) ((. x "valueOf"))) (list values ...))))))) "(let-values binding body ...) + +The macro work similar to let but variable is list of values and value +need to evaluate to result of calling values.")(define (vector-append . args) "(vector-append v1 v2 ...) + +Function return new vector by combining it's arguments that should be vectors." (if (null? args) (vector) (begin (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args)))))))(define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...) + +The macro work similar to let* but variable is list of values and value +need to evaluate to result of calling values.")(define (quotient&remainder x y) (values (quotient x y) (remainder x y)))(define (floor/ x y) (let ((q (quotient x y)) (r (remainder x y))) (if (>= x 0) (if (or (> y 0) (zero? r)) (values q r) (values (- q 1) (+ r y))) (if (and (> y 0) (not (zero? r))) (values (- q 1) (+ r y)) (values q r)))))(define (floor-quotient x y) (values-ref (floor/ x y) 0))(define (floor-remainder x y) (modulo x y))(define (truncate/ x y) (quotient&remainder x y))(define (truncate-quotient x y) (quotient x y))(define (truncate-remainder x y) (remainder x y))(define-syntax case-lambda (syntax-rules () ((case-lambda (params body0 ...) ...) (lambda args (let ((len (length args))) (letrec-syntax ((cl (syntax-rules ::: () ((cl) (error "no matching clause")) ((cl ((p :::) . body) . rest) (if (= len (length (quote (p :::)))) (apply (lambda (p :::) . body) args) (cl . rest))) ((cl ((p ::: . tail) . body) . rest) (if (>= len (length (quote (p :::)))) (apply (lambda (p ::: . tail) . body) args) (cl . rest)))))) (cl (params body0 ...) ...)))))) "(case-lambda expr ...) + +Macro create new function with different version of the function depend on +number of arguments. Each expression is similar to single lambda. + +e.g.: + + (define sum + (case-lambda + ((x) x) + ((x y) (+ x y)) + ((x y z) (+ x y z)))) + + (sum 1) + (sum 1 2) + (sum 1 2 3) + +More arguments will give error.")(define (boolean=? . args) "(boolean=? b1 b2 ...) + +Function check if all arguments are boolean and if they are the same." (if (< (length args) 2) (error "boolean=?: too few arguments") (reduce (lambda (acc item) (and (boolean? item) (eq? acc item))) (car args) (cdr args))))(define (port? x) "(port? x) + +Function return true of argumet is nput or output port port object." (or (output-port? x) (input-port? x)))(define (square x) "(square z) + +Returns the square of z. This is equivalent to (* z z)." (* x x))(define-syntax when (syntax-rules () ((when test result1 result2 ...) (if test (begin result1 result2 ...)))) "(when test body ...) + +Macro execute body when test expression is true.")(define-syntax unless (syntax-rules () ((unless test result1 result2 ...) (if (not test) (begin result1 result2 ...)))) "(unless test body ...) + +Macro execute body when test expression is false.")(define inexact exact->inexact)(define exact inexact->exact)(define (exact-integer? n) "(exact-integer? n) + +Function returns #t if z is both exact and an integer; otherwise +returns #f." (and (integer? n) (exact? n)))(define (string->vector s) "(string->vector string) + +Function return vector of characters created from string." (typecheck "string->list" s "string") (--> s (split "") (map (lambda (x) (lips.LCharacter x)))))(define (vector->string v) "(vector->string vector) + +Function return new string created from vector of characters." (typecheck "vector->list" v "array") (--> v (map (lambda (char) (char.valueOf))) (join "")))(define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...) + +Function return new vector from applying function fn to each element +of the vectors, similar to map for lists." (if (or (= (length rest) 0) (not (every vector? rest))) (error "vector-map: function require at least 1 vector") (let ((len (apply min (map vector-length rest))) (result (vector))) (do ((i 0 (+ i 1))) ((= i len) result) (let* ((args (map (lambda (v) (vector-ref v i)) rest)) (value (apply fn args))) (--> result (push value)))))))(define (string-map fn . rest) "(string-map fn string1 stringr2 ...) + +Function return new string from applying function fn to each element +of the strings, similar to map for lists." (if (or (= (length rest) 0) (not (every string? rest))) (error "string-map: function require at least 1 string") (vector->string (apply vector-map fn (map string->vector rest)))))(define (dynamic-wind before thunk after) "(dynamic-wind before thunk after) + +Function accept 3 procedures/lambdas and execute thunk with before and always +after even if error accur" (before) (let ((result (try (thunk) (catch (e) (error e))))) (after) result))(define (with-exception-handler handler thunk) "(with-exception-handler handler thunk) + +Procedure call and return value of thunk function, if exception happen +it call handler procedure." (try (thunk) (catch (e) (handler e))))(define raise throw)(define-syntax define-values (syntax-rules () ((define-values () expr) (define dummy (call-with-values (lambda () expr) (lambda args #f)))) ((define-values (var) expr) (define var expr)) ((define-values (var0 var1 ... varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cadr var0))) (set! var0 (car var0)) v)))) ((define-values (var0 var1 ... . varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cdr var0))) (set! var0 (car var0)) v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) list)))) "(define-values (a b ...) expr) + +Function evaluate expression expr and if it evaluates to result of values +then it will defined each value as variable like with define.")(define-macro (include . files) "(include file ...) + +Macro that load at least one file content and insert them into one, +body expression." (if (null? files) (throw (new Error "include: at least one file path required")) (let ((result (vector)) (env (interaction-environment))) (if (eq? self global) (let* ((fs (require "fs")) (readFile (lambda (file) (new Promise (lambda (resolve reject) (fs.readFile file (lambda (err data) (if (null? err) (resolve (--> data (toString))) (reject err))))))))) (for-each (lambda (file) (let* ((expr (lips.parse (readFile file) env))) (set! result (--> result (concat expr))))) files)) (for-each (lambda (file) (let* ((text (--> (fetch file) (text))) (expr (lips.parse text env))) (set! result (--> result (concat expr))))) files)) (if (> result.length 0) (quasiquote (begin (unquote-splicing (vector->list result))))))))(define-syntax syntax-error (syntax-rules () ((_ "step" arg ...) (join " " (vector->list (vector (repr arg) ...)))) ((_ message arg ...) (raise (new Error (format "~a ~a" message (_ "step" arg ...)))))))(define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...))))(define (features) (quote (r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower)))(define *zero-number-chars* #(48 1632 1776 1984 2406 2534 2662 2790 2918 3046 3174 3302 3430 3558 3664 3792 3872 4160 4240 6112 6160 6470 6608 6784 6800 6992 7088 7232 7248 42528 43216 43264 43472 43504 43600 44016 65296 66720 68912 69734 69872 69942 70096 70384 70736 70864 71248 71360 71472 71904 72016 72784 73040 73120 92768 93008 120782 120792 120802 120812 120822 123200 123632 125264 130032))(define (digit-value chr) "(digit-value chr) + +Return digit number if character is numeral (as per char-numeric?) +or #f otherwise." (typecheck "digit-value" chr "character") (if (char-numeric? chr) (let ((ord (char->integer chr))) (do ((i (vector-length *zero-number-chars*) (- i 1)) (found #f) (result #f)) ((or (zero? i) found) result) (let* ((zero (vector-ref *zero-number-chars* (- i 1))) (diff (- ord zero))) (if (and (>= diff 0) (<= diff 9)) (begin (set! result diff) (set! found #t)))))) #f))(define make-bytevector make-u8vector)(define bytevector u8vector)(define bytevector? u8vector?)(define bytevector-length u8vector-length)(define bytevector-u8-ref u8vector-ref)(define bytevector-u8-set! u8vector-set!)(define (bytevector-append v1 . rest) "(bytevector-append v1 ...) + +Create new bytevector u8vector that is created from joining each argument." (typecheck "bytevector-append" v1 "uint8array" 1) (map (lambda (arg) (typecheck "bytevector-append" arg "uint8array")) rest) (if (null? rest) v1 (new Uint8Array (apply vector-append (Array.from v1) (map Array.from rest)))))(define (bytevector-copy v . rest) "(bytevector-copy v) +(bytevector-copy v start) +(bytevector-copy v start end) + +Function and return new vector from start to end. If no start and end is provided +whole vector is copied and returned." (if (null? rest) (new Uint8Array v) (let ((start (car rest))) (if (null? (cdr rest)) (v.slice start) (v.slice start (cadr rest))))))(define (bytevector-copy! to at from . rest) "(bytevector-copy! to at from) +(bytevector-copy! to at from start) +(bytevector-copy! to at from start end) + +Copies the bytes of bytevector from between start and end to bytevector to, +starting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1))))))(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end)))))))(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end)))))))(define (open-input-string string) "(open-input-string string) + +Function create new string port as input that can be used to +read S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment)))(define (open-output-string) "(open-output-string) + +Function create new output port that can used to write string into +and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr))(define (get-output-string port) "(get-output-string port) + +Function get full string from string port. If nothing was wrote +to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define delete-file (let ((unlink #f)) (lambda (filename) (typecheck "delete-file" filename "string") (if (null? self.fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename))))))(define (call-with-port port proc) "(call-with-port port proc) + +Proc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close)))))(define (close-port port) "(close-port port) + +Close input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close))(define (eof-object) "(eof-object) + +Procedure returns eof object that indicate end of the port" lips.eof)(define (output-port-open? port) "(output-port-open? port) + +Function check if argument is output-port and if you can write to it." (and (output-port? port) (port.is_open)))(define (input-port-open? port) "(input-port-open? port) + +Function check if argument is input-port and if you can read from it." (and (input-port? port) (port.is_open)))(define (flush-output-port port) "(flush-output-port port) + +Functio do nothing, flush is not needed in LIPS in both NodeJS and Browser. +The function is added, so it don't throw exception when using R7RS code." (if #f #f))(define (write-string string . rest) "(write-string string) +(write-string string port) +(write-string string port start) +(write-string string port start end) + +Writes the characters of string from start to end in left-toright order +to the textual output port." (typecheck "write-string" string "string") (let ((port (if (null? rest) (current-output-port) (car rest))) (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) (string-length string) (caddr rest)))) (typecheck "write-string" port "output-port") (typecheck "write-string" start "number") (typecheck "write-string" end "number") (display (substring string start end) port)))(define (write-char char . rest) "(write-char string) +(write-char string port) + +Writes the character char (not an external representation of the character) +to the given textual output port and returns an unspecified value." (typecheck "write-char" char "character") (let ((port (if (null? rest) (current-output-port) (car rest)))) (typecheck "write-char" port "output-port") (display (string char) port)))(define (read-string k . rest) "(read-string k) +(read-string k port) + +Reads the next k characters, or as many as are available +before the end of file, from the textual input port into a +newly allocated string in left-to-right order and returns the +string. If no characters are available before the end of file, +an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k))) \ No newline at end of file diff --git a/lib/js/bookmark.js b/lib/js/bookmark.js old mode 100644 new mode 100755 index 41c448ce..11a6e70b --- a/lib/js/bookmark.js +++ b/lib/js/bookmark.js @@ -102,7 +102,7 @@ javascript:(function(next) { var path = `https://cdn.jsdelivr.net/gh/jcubic/lips@${REF}/`; term.exec([ '(let ((e lips.env.__parent__))', - '(load "' + path + 'dist/std.scm" e))' + '(load "' + path + 'dist/std.min.scm" e))' ].join('\n'), true); } function format_baner(banner) { diff --git a/scripts/minify.scm b/scripts/minify.scm new file mode 100755 index 00000000..6b4ed93c --- /dev/null +++ b/scripts/minify.scm @@ -0,0 +1,9 @@ +#!/usr/bin/env lips + +(if (= process.argv.length 4) + (let* ((fs (require "fs")) + (buff (fs.promises.readFile (. process.argv 3))) + (port (open-input-string (--> buff (toString))))) + (do ((expr (read port) (read port))) + ((eq? expr eof)) + (write expr)))) \ No newline at end of file diff --git a/templates/Makefile b/templates/Makefile index 64e99527..e4aa4017 100755 --- a/templates/Makefile +++ b/templates/Makefile @@ -29,8 +29,9 @@ MERMAID=./node_modules/.bin/mmdc NPM=npm UGLIFY=./node_modules/.bin/uglifyjs ROLLUP=./node_modules/.bin/rollup +LIPS=./bin/lips.js -ALL: Makefile package.json .$(VERSION) assets/classDiagram.svg dist/lips.js dist/lips.min.js README.md dist/std.scm +ALL: Makefile package.json .$(VERSION) assets/classDiagram.svg dist/lips.js dist/lips.min.js README.md dist/std.min.scm dist/lips.js: src/lips.js .$(VERSION) rollup.config.js $(ROLLUP) -c @@ -48,6 +49,9 @@ dist/lips.min.js: dist/lips.js .$(VERSION) dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm > dist/std.scm +dist/std.min.scm: dist/std.scm + $(LIPS) ./scripts/minify.scm dist/std.scm > dist/std.min.scm + Makefile: templates/Makefile $(SED) -e "s/{{VER""SION}}/"$(VERSION)"/g" templates/Makefile > Makefile From 0bfc516de2b0ed2faf6d595e3af5feb0475dea2c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 12 Feb 2021 11:45:59 +0100 Subject: [PATCH 002/109] fix prism highlighting of names (for new context help) --- CHANGELOG.md | 6 ++++++ lib/js/prism.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 CHANGELOG.md mode change 100644 => 100755 lib/js/prism.js diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100644 new mode 100755 index 8405cf24..a8c40280 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.0-beta.12 +### Features +* create minfied std scheme file for faster bootstrap +### Bugfix +* fix prism highlighting of names (for new context help) + ## 1.0.0-beta.11 ### Breaking * remove repr of HTMLElement (it's now default instance of a class) diff --git a/lib/js/prism.js b/lib/js/prism.js old mode 100644 new mode 100755 index 49efe3a7..ad6409ea --- a/lib/js/prism.js +++ b/lib/js/prism.js @@ -39,6 +39,6 @@ var keyword = Prism.languages.scheme.keyword.pattern; Prism.languages.scheme.keyword.pattern = new RegExp(keyword.source.replace(/\|when/, '|when|set-obj!|let-env|try|catch|throw|raise')); // names should be marked so we can show help message on higher order function that have function as argument Prism.languages.scheme.name = { - pattern: /(^|[()[\]\s])[^#][^()\s]*/g, + pattern: /(^|[()[\]\s][^#])[^()\s]*/g, lookbehind: true }; From 3218579dfa2bc60b6701f1426bd34fcde344f733 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 12 Feb 2021 19:30:58 +0100 Subject: [PATCH 003/109] add `list-copy` procedure The procedure call Pair::clone and it require updating it, to enable shallow copy --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 17 ++++++++++++----- dist/lips.min.js | 6 +++--- dist/std.min.scm | 4 +++- dist/std.scm | 13 ++++++++++++- lib/R7RS.scm | 13 ++++++++++++- src/lips.js | 8 ++++++-- 8 files changed, 51 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8c40280..49cf89e2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.0-beta.12 ### Features * create minfied std scheme file for faster bootstrap +* add `list-copy` ### Bugfix * fix prism highlighting of names (for new context help) diff --git a/README.md b/README.md index e39e4b77..5a66396d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&e03fd96e5d4b588bb149ed2f2db2296885f8d98d)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&4bc93f9a519c2e3dab7277f4f453e29b)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&0bfc516de2b0ed2faf6d595e3af5feb0475dea2c)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index db4af057..c9a3960a 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 12 Feb 2021 10:31:11 +0000 + * build: Fri, 12 Feb 2021 18:27:04 +0000 */ (function () { 'use strict'; @@ -4213,6 +4213,7 @@ Pair.prototype.clone = function () { + var deep = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : true; var visited = new Map(); function clone(node) { @@ -4223,7 +4224,13 @@ var pair = new Pair(); visited.set(node, pair); - pair.car = clone(node.car); + + if (deep) { + pair.car = clone(node.car); + } else { + pair.car = node.car; + } + pair.cdr = clone(node.cdr); pair[__cycles__] = node[__cycles__]; return pair; @@ -13034,10 +13041,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 12 Feb 2021 10:31:11 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 12 Feb 2021 18:27:04 +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('Fri, 12 Feb 2021 10:31:11 +0000').valueOf(); + var date = LString('Fri, 12 Feb 2021 18:27:04 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13074,7 +13081,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 12 Feb 2021 10:31:11 +0000', + date: 'Fri, 12 Feb 2021 18:27:04 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index c776a015..3e29eadc 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -4,7 +4,7 @@ * | | \ \ | | | || . \/ __> | | * | | > \ | |_ | || _/\__ \ | | * | | / ^ \ |___||_||_| <___/ | | - * \_\ /_/ \_\ /_/ v. 1.0.0-beta.11 + * \_\ /_/ \_\ /_/ v. DEV * * 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: Sun, 31 Jan 2021 11:47:57 +0000 + * build: Fri, 12 Feb 2021 18:27:04 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=new Map;function t(e){if(e instanceof Pair){if(n.has(e)){return n.get(e)}var r=new Pair;n.set(e,r);r.car=t(e.car);r.cdr=t(e.cdr);r[__cycles__]=e[__cycles__];return r}return e}return t(this)};Pair.prototype.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 31 Jan 2021 11:47:57 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter 1.0.0-beta.11 (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"1.0.0-beta.11",banner:banner,date:"Sun, 31 Jan 2021 11:47:57 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 12 Feb 2021 18:27:04 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Fri, 12 Feb 2021 18:27:04 +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,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/dist/std.min.scm b/dist/std.min.scm index 5b7545e9..44840e7b 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -682,4 +682,6 @@ Reads the next k characters, or as many as are available before the end of file, from the textual input port into a newly allocated string in left-to-right order and returns the string. If no characters are available before the end of file, -an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k))) \ No newline at end of file +an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k)))(define (list-copy obj) "(list-copy obj) + +Copy the object passed as argument but only if it's list" (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index cfcf6e79..13d43630 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3387,7 +3387,6 @@ (display (string char) port))) ;; ----------------------------------------------------------------------------- - (define (read-string k . rest) "(read-string k) (read-string k port) @@ -3401,3 +3400,15 @@ (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k))) + +;; ----------------------------------------------------------------------------- +(define (list-copy obj) + "(list-copy obj) + + Copy the object passed as argument but only if it's list" + (typecheck "list-copy" obj #("pair" "nil")) + (if (null? obj) + obj + (obj.clone false))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 52c577ef..32295378 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -683,7 +683,6 @@ (display (string char) port))) ;; ----------------------------------------------------------------------------- - (define (read-string k . rest) "(read-string k) (read-string k port) @@ -697,3 +696,15 @@ (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k))) + +;; ----------------------------------------------------------------------------- +(define (list-copy obj) + "(list-copy obj) + + Copy the object passed as argument but only if it's list" + (typecheck "list-copy" obj #("pair" "nil")) + (if (null? obj) + obj + (obj.clone false))) + +;; ----------------------------------------------------------------------------- diff --git a/src/lips.js b/src/lips.js index 590c7d75..4699d207 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2150,7 +2150,7 @@ }; // ---------------------------------------------------------------------- - Pair.prototype.clone = function() { + Pair.prototype.clone = function(deep = true) { var visited = new Map(); function clone(node) { if (node instanceof Pair) { @@ -2159,7 +2159,11 @@ } var pair = new Pair(); visited.set(node, pair); - pair.car = clone(node.car); + if (deep) { + pair.car = clone(node.car); + } else { + pair.car = node.car; + } pair.cdr = clone(node.cdr); pair[__cycles__] = node[__cycles__]; return pair; From d48e0b5c6a5e88beae21e03c3fd06d46aa915a72 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 13 Feb 2021 13:47:42 +0100 Subject: [PATCH 004/109] update doc string for list-copy --- dist/std.min.scm | 3 ++- dist/std.scm | 3 ++- lib/R7RS.scm | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index 44840e7b..e62c6e64 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -684,4 +684,5 @@ newly allocated string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k)))(define (list-copy obj) "(list-copy obj) -Copy the object passed as argument but only if it's list" (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f))) \ No newline at end of file +Copy the object passed as argument but only if it's list. The car elements +of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index 13d43630..0115b9c4 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3405,7 +3405,8 @@ (define (list-copy obj) "(list-copy obj) - Copy the object passed as argument but only if it's list" + Copy the object passed as argument but only if it's list. The car elements + of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 32295378..46b8de21 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -701,7 +701,8 @@ (define (list-copy obj) "(list-copy obj) - Copy the object passed as argument but only if it's list" + Copy the object passed as argument but only if it's list. The car elements + of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj From 1c57d81a06cb802534152b75886fedb5571b20a8 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 13 Feb 2021 18:33:04 +0100 Subject: [PATCH 005/109] add R7RS records (define-record-type macro) --- CHANGELOG.md | 1 + README.md | 2 +- dist/lips.js | 14 +++++++---- dist/lips.min.js | 4 ++-- dist/std.min.scm | 17 +++++++++++++- dist/std.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/R7RS.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lips.js | 5 +++- 8 files changed, 153 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49cf89e2..6c2e59c6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Features * create minfied std scheme file for faster bootstrap * add `list-copy` +* add `define-record-type` ### Bugfix * fix prism highlighting of names (for new context help) diff --git a/README.md b/README.md index 5a66396d..27b42f6c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&0bfc516de2b0ed2faf6d595e3af5feb0475dea2c)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&d48e0b5c6a5e88beae21e03c3fd06d46aa915a72)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index c9a3960a..09f2e063 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 12 Feb 2021 18:27:04 +0000 + * build: Sat, 13 Feb 2021 17:31:35 +0000 */ (function () { 'use strict'; @@ -3701,7 +3701,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { @@ -12155,6 +12155,10 @@ obj.__instance__ = false; if (obj.__instance__) { + if (is_function(obj.toType)) { + return obj.toType(); + } + return 'instance'; } } @@ -13041,10 +13045,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 12 Feb 2021 18:27:04 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 13 Feb 2021 17:31:35 +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('Fri, 12 Feb 2021 18:27:04 +0000').valueOf(); + var date = LString('Sat, 13 Feb 2021 17:31:35 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13081,7 +13085,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 12 Feb 2021 18:27:04 +0000', + date: 'Sat, 13 Feb 2021 17:31:35 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 3e29eadc..846577e5 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 12 Feb 2021 18:27:04 +0000 + * build: Sat, 13 Feb 2021 17:31:35 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 12 Feb 2021 18:27:04 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Fri, 12 Feb 2021 18:27:04 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 17:31:35 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 17:31:35 +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,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/dist/std.min.scm b/dist/std.min.scm index e62c6e64..61d503f4 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -685,4 +685,19 @@ string. If no characters are available before the end of file, an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k)))(define (list-copy obj) "(list-copy obj) Copy the object passed as argument but only if it's list. The car elements -of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f))) \ No newline at end of file +of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f)))(define-macro (define-record-type name constructor pred . fields) "(define-record-type name constructor pred . fields) + +Macro for defining records. Example of usage: + + (define-record-type <pare> + (kons x y) + pare? + (x kar set-kar!) + (y kdr set-kdr!)) + +(define p (kons 1 2)) +(print (kar p)) +;; 1 +(set-kdr! p 3) +(print (kdr p)) +;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields)))))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index 0115b9c4..ee23e4db 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3413,3 +3413,63 @@ (obj.clone false))) ;; ----------------------------------------------------------------------------- +(define-macro (define-record-type name constructor pred . fields) + "(define-record-type name constructor pred . fields) + + Macro for defining records. Example of usage: + + (define-record-type <pare> + (kons x y) + pare? + (x kar set-kar!) + (y kdr set-kdr!)) + + (define p (kons 1 2)) + (print (kar p)) + ;; 1 + (set-kdr! p 3) + (print (kdr p)) + ;; 3" + (let ((class-name (gensym)) + (obj-name (gensym)) + (value-name (gensym))) + `(begin + (define ,class-name (class Object + (constructor (lambda (self ,@(cdr constructor)) + ,@(map (lambda (field) + (let* ((name (symbol->string field)) + (prop (string-append "self." + name))) + `(set! ,(string->symbol prop) ,field))) + (cdr constructor)))) + (toType (lambda (self) + "record")) + (toString (lambda (self) + ,(symbol->string name))))) + (define ,constructor + (new ,class-name ,@(cdr constructor))) + (define (,pred obj) + (instanceof ,class-name obj)) + ,@(map (lambda (field) + (let ((prop-name (car field)) + (get (cadr field)) + (set (if (null? (cddr field)) + nil + (caddr field)))) + `(begin + (define (,get ,obj-name) + (typecheck ,(symbol->string get) ,obj-name "record") + (if (not (,pred ,obj-name)) + (throw (new Error ,(string-append "object is not record of type " + (symbol->string name)))) + (. ,obj-name ',prop-name))) + ,(if (not (null? set)) + `(define (,set ,obj-name ,value-name) + (typecheck ,(symbol->string get) ,obj-name "record") + (if (not (,pred ,obj-name)) + (throw (new Error ,(string-append "object is not record of type " + (symbol->string name)))) + (set-obj! ,obj-name ',prop-name ,value-name))))))) + fields)))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 46b8de21..ab473a78 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -709,3 +709,63 @@ (obj.clone false))) ;; ----------------------------------------------------------------------------- +(define-macro (define-record-type name constructor pred . fields) + "(define-record-type name constructor pred . fields) + + Macro for defining records. Example of usage: + + (define-record-type <pare> + (kons x y) + pare? + (x kar set-kar!) + (y kdr set-kdr!)) + + (define p (kons 1 2)) + (print (kar p)) + ;; 1 + (set-kdr! p 3) + (print (kdr p)) + ;; 3" + (let ((class-name (gensym)) + (obj-name (gensym)) + (value-name (gensym))) + `(begin + (define ,class-name (class Object + (constructor (lambda (self ,@(cdr constructor)) + ,@(map (lambda (field) + (let* ((name (symbol->string field)) + (prop (string-append "self." + name))) + `(set! ,(string->symbol prop) ,field))) + (cdr constructor)))) + (toType (lambda (self) + "record")) + (toString (lambda (self) + ,(symbol->string name))))) + (define ,constructor + (new ,class-name ,@(cdr constructor))) + (define (,pred obj) + (instanceof ,class-name obj)) + ,@(map (lambda (field) + (let ((prop-name (car field)) + (get (cadr field)) + (set (if (null? (cddr field)) + nil + (caddr field)))) + `(begin + (define (,get ,obj-name) + (typecheck ,(symbol->string get) ,obj-name "record") + (if (not (,pred ,obj-name)) + (throw (new Error ,(string-append "object is not record of type " + (symbol->string name)))) + (. ,obj-name ',prop-name))) + ,(if (not (null? set)) + `(define (,set ,obj-name ,value-name) + (typecheck ,(symbol->string get) ,obj-name "record") + (if (not (,pred ,obj-name)) + (throw (new Error ,(string-append "object is not record of type " + (symbol->string name)))) + (set-obj! ,obj-name ',prop-name ,value-name))))))) + fields)))) + +;; ----------------------------------------------------------------------------- diff --git a/src/lips.js b/src/lips.js index 4699d207..9d5efeab 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1744,7 +1744,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { @@ -8581,6 +8581,9 @@ if (obj.__instance__) { obj.__instance__ = false; if (obj.__instance__) { + if (is_function(obj.toType)) { + return obj.toType(); + } return 'instance'; } } From 73823f0480ca1bce6d4a2a8337ee15f34d8ac2c9 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 13 Feb 2021 21:12:26 +0100 Subject: [PATCH 006/109] 2 space indent for define-record-type --- README.md | 2 +- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 27b42f6c..a9014fde 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&d48e0b5c6a5e88beae21e03c3fd06d46aa915a72)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&1c57d81a06cb802534152b75886fedb5571b20a8)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 09f2e063..177553c3 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 17:31:35 +0000 + * build: Sat, 13 Feb 2021 20:12:16 +0000 */ (function () { 'use strict'; @@ -3701,7 +3701,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { @@ -13045,10 +13045,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 13 Feb 2021 17:31:35 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 13 Feb 2021 20:12:16 +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('Sat, 13 Feb 2021 17:31:35 +0000').valueOf(); + var date = LString('Sat, 13 Feb 2021 20:12:16 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13085,7 +13085,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 13 Feb 2021 17:31:35 +0000', + date: 'Sat, 13 Feb 2021 20:12:16 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 846577e5..7ecded19 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 17:31:35 +0000 + * build: Sat, 13 Feb 2021 20:12:16 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.length}}function Formatter(e){this.__code__=e.replace(/\r/g,"")}Formatter.defaults={offset:0,indent:2,exceptions:{specials:[/^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 17:31:35 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 17:31:35 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 20:12:16 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 20:12:16 +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,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/src/lips.js b/src/lips.js index 9d5efeab..7731bc45 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1744,7 +1744,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { From 547d29f33891ee38c4a94aebfe4a5ae16cfb0090 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 13 Feb 2021 22:16:42 +0100 Subject: [PATCH 007/109] update preact example --- examples/preact.html | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/preact.html b/examples/preact.html index acf2a378..93738ea9 100644 --- a/examples/preact.html +++ b/examples/preact.html @@ -9,13 +9,7 @@ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="https://unpkg.com/preact@8.4.2/dist/preact.min.js"></script> - <script src="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/dist/lips.js"></script> - <script type="text/x-scheme"> - (let-env lips.env.parent - (load "https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/bootstrap.scm") - (load "https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/R5RS.scm") - (load "https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/R7RS.scm")) - </script> + <script src="https://cdn.jsdelivr.net/gh/jcubic/lips@devel/dist/lips.js" bootstrap></script> <script type="text/x-scheme" src="preact.scm"></script> </head> <body> From d6d8cd0ccb40ed9d38c93cbaea4bae5ad8ba943a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 13 Feb 2021 22:19:57 +0100 Subject: [PATCH 008/109] fix env + add docs for scheme-report-environment The env was broken when passing output of scheme-report-environment --- dist/lips.js | 12 ++++++------ dist/lips.min.js | 4 ++-- dist/std.min.scm | 5 ++++- dist/std.scm | 4 ++++ lib/R5RS.scm | 4 ++++ src/lips.js | 8 +++++--- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/dist/lips.js b/dist/lips.js index 177553c3..e900155f 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 20:12:16 +0000 + * build: Sat, 13 Feb 2021 20:32:39 +0000 */ (function () { 'use strict'; @@ -11110,12 +11110,12 @@ result = nil; } - if (env.__parent__ !== undefined$1) { + if (env.__parent__ instanceof Environment) { return global_env.get('env')(env.__parent__).append(result); } return result; - }, "(env obj)\n\n Function return list values (functions and variables) inside environment."), + }, "(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."), // ------------------------------------------------------------------ 'new': doc('new', function (obj) { for (var _len26 = arguments.length, args = new Array(_len26 > 1 ? _len26 - 1 : 0), _key26 = 1; _key26 < _len26; _key26++) { @@ -13045,10 +13045,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 13 Feb 2021 20:12:16 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 13 Feb 2021 20:32:39 +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('Sat, 13 Feb 2021 20:12:16 +0000').valueOf(); + var date = LString('Sat, 13 Feb 2021 20:32:39 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13085,7 +13085,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 13 Feb 2021 20:12:16 +0000', + date: 'Sat, 13 Feb 2021 20:32:39 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 7ecded19..7760143e 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 20:12:16 +0000 + * build: Sat, 13 Feb 2021 20:32:39 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__!==undefined$1){return global_env.get("env")(e.__parent__).append(n)}return n},"(env obj)\n\n Function return list values (functions and variables) inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 20:12:16 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 20:12:16 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 20:32:39 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 20:32:39 +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,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/dist/std.min.scm b/dist/std.min.scm index 61d503f4..1e19dd54 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -545,7 +545,10 @@ After thunk is executed current-input-port is restored and file port is closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port)))))(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port)))))(define (file-exists? filename) (new Promise (lambda (resolve) (if (null? self.fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename) Function open file and return port that can be used for writing. If file -exists it will throw an Error." (typecheck "open-output-file" filename "string") (if (null? self.fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))(define (scheme-report-environment version) (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported"))))))(define-macro (%make-vector prefix type help) "(%make-vector prefix type help) +exists it will throw an Error." (typecheck "open-output-file" filename "string") (if (null? self.fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))(define (scheme-report-environment version) "(scheme-report-environment version) + +Function return new Environment object for given Scheme Spec version. +Only argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported"))))))(define-macro (%make-vector prefix type help) "(%make-vector prefix type help) Mega helper macro that create list of functions for single byte vector based on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...) diff --git a/dist/std.scm b/dist/std.scm index ee23e4db..cf91e458 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2533,6 +2533,10 @@ ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) + "(scheme-report-environment version) + + Function return new Environment object for given Scheme Spec version. + Only argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 0257b25d..c4b2ccb1 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -1325,6 +1325,10 @@ ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) + "(scheme-report-environment version) + + Function return new Environment object for given Scheme Spec version. + Only argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv diff --git a/src/lips.js b/src/lips.js index 7731bc45..8f833cc5 100644 --- a/src/lips.js +++ b/src/lips.js @@ -7499,13 +7499,15 @@ } else { result = nil; } - if (env.__parent__ !== undefined) { + if (env.__parent__ instanceof Environment) { return global_env.get('env')(env.__parent__).append(result); } return result; - }, `(env obj) + }, `(env) + (env obj) - Function return list values (functions and variables) inside environment.`), + Function return list of values (functions, macros and variables) + inside environment.`), // ------------------------------------------------------------------ 'new': doc('new', function(obj, ...args) { var instance = new (unbind(obj))(...args.map(x => unbox(x))); From a9403215b546397950a08fa0503b71440c480b64 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Feb 2021 11:42:37 +0100 Subject: [PATCH 009/109] return 0 on (truncate 0) --- README.md | 2 +- dist/lips.js | 12 +++++++----- dist/lips.min.js | 4 ++-- src/lips.js | 4 +++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c0bc02a0..087b5b6e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&d6d8cd0ccb40ed9d38c93cbaea4bae5ad8ba943a)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&1da0f91e428abf3af19d8a544868737bd30d4470)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index e900155f..78f93761 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 20:32:39 +0000 + * build: Sun, 14 Feb 2021 10:42:14 +0000 */ (function () { 'use strict'; @@ -5134,7 +5134,9 @@ return Math.trunc; } else { return function (x) { - if (x < 0) { + if (x === 0) { + return 0; + } else if (x < 0) { return Math.ceil(x); } else { return Math.floor(x); @@ -13045,10 +13047,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 13 Feb 2021 20:32:39 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 14 Feb 2021 10:42:14 +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('Sat, 13 Feb 2021 20:32:39 +0000').valueOf(); + var date = LString('Sun, 14 Feb 2021 10:42:14 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13085,7 +13087,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 13 Feb 2021 20:32:39 +0000', + date: 'Sun, 14 Feb 2021 10:42:14 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 7760143e..409428ac 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 13 Feb 2021 20:32:39 +0000 + * build: Sun, 14 Feb 2021 10:42:14 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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 Math.ceil(e)}else{return Math.floor(e)}}}}();function Macro(e,r,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 13 Feb 2021 20:32:39 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sat, 13 Feb 2021 20:32:39 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 10:42:14 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 10:42:14 +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,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/src/lips.js b/src/lips.js index 8f833cc5..8ed855df 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2902,7 +2902,9 @@ return Math.trunc; } else { return function(x) { - if (x < 0) { + if (x === 0) { + return 0; + } else if (x < 0) { return Math.ceil(x); } else { return Math.floor(x); From 3cb351e69b8823be001123c797345a1c95d93566 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Feb 2021 12:36:38 +0100 Subject: [PATCH 010/109] update to env, apropos and help env now return symbols apropos now accept symbols and properly escape regex operators add new escape-regex function --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- bin/lips.js | 4 +++- dist/lips.js | 35 +++++++++++++++++++++-------------- dist/lips.min.js | 4 ++-- dist/std.min.scm | 2 +- dist/std.scm | 14 ++++++++------ lib/bootstrap.scm | 14 ++++++++------ lib/js/bookmark.js | 4 ++-- src/lips.js | 18 ++++++++++++++---- tests/numbers.scm | 24 ++++++++++++++++++++++++ 11 files changed, 91 insertions(+), 38 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c2e59c6..8672d56b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,16 @@ ## 1.0.0-beta.12 +### Breaking +* `env` now return symbols instead of strings ### Features * create minfied std scheme file for faster bootstrap * add `list-copy` * add `define-record-type` +* add `escape-regex` function +* make `apropos` accept symbol as argument ### Bugfix * fix prism highlighting of names (for new context help) +* fix error when using help in node REPL and there are no doc string +* fix escaping regex operators when using string with `apropos` ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 087b5b6e..cdc1e046 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&1da0f91e428abf3af19d8a544868737bd30d4470)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&83772d306416614a34e010475a6264c0)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a9403215b546397950a08fa0503b71440c480b64)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&af78f435cce019a2635ef216e055bb63)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/bin/lips.js b/bin/lips.js index 79919b02..079bd89b 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -190,7 +190,9 @@ var interp = Interpreter('repl', { help: doc(new Macro('help', function(code, { error }) { var new_code = new Pair(new LSymbol('__help'), code); var doc = evaluate(new_code, { env: this, error }); - console.log(doc.toString()); + if (doc) { + console.log(doc.toString()); + } }), env.get('help').__doc__), '__help': env.get('help') }); diff --git a/dist/lips.js b/dist/lips.js index 78f93761..98721729 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 10:42:14 +0000 + * build: Sun, 14 Feb 2021 11:28:22 +0000 */ (function () { 'use strict'; @@ -1715,6 +1715,10 @@ re = LNumber(0); } + if (im.cmp(0) === 0) { + return re; + } + return LComplex({ im: im, re: re @@ -1881,19 +1885,17 @@ var string_re = /"(?:\\[\S\s]|[^"])*"?/g; // ---------------------------------------------------------------------- - /* function escape_regex(str) { - if (typeof str === 'string') { - var special = /([-\\^$[\]()+{}?*.|])/g; - return str.replace(special, '\\$1'); - } - } - */ - // ---------------------------------------------------------------------- + if (typeof str === 'string') { + var special = /([-\\^$[\]()+{}?*.|])/g; + return str.replace(special, '\\$1'); + } + } // ---------------------------------------------------------------------- // Stack used in balanced function // TODO: use it in parser // ---------------------------------------------------------------------- + function Stack() { this.data = []; } @@ -11100,9 +11102,14 @@ return toString(obj, quote); }, "(repr obj)\n\n Function return string LIPS representation of an object as string."), // ------------------------------------------------------------------ + 'escape-regex': doc('escape-regex', function (string) { + typecheck('escape-regex', string, 'string'); + return escape_regex(string.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 env(env) { env = env || this; - var names = Object.keys(env.__env__); // TODO: get symbols + var names = Object.keys(env.__env__).map(LSymbol); // TODO: get symbols var result; @@ -11117,7 +11124,7 @@ } return result; - }, "(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."), + }, "(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 (obj) { for (var _len26 = arguments.length, args = new Array(_len26 > 1 ? _len26 - 1 : 0), _key26 = 1; _key26 < _len26; _key26++) { @@ -13047,10 +13054,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 14 Feb 2021 10:42:14 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 14 Feb 2021 11:28:22 +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('Sun, 14 Feb 2021 10:42:14 +0000').valueOf(); + var date = LString('Sun, 14 Feb 2021 11:28:22 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13087,7 +13094,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 14 Feb 2021 10:42:14 +0000', + date: 'Sun, 14 Feb 2021 11:28:22 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 409428ac..28fafcfb 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 10:42:14 +0000 + * build: Sun, 14 Feb 2021 11:28:22 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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 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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(repr obj)\n\n Function return string LIPS representation of an object as string."),env:doc(function e(e){e=e||this;var r=Object.keys(e.__env__);var n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(env)\n (env obj)\n\n Function return list of values (functions, macros and variables)\n inside environment."),new:doc("new",function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 10:42:14 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 10:42:14 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 11:28:22 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 11:28:22 +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,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/dist/std.min.scm b/dist/std.min.scm index 1e19dd54..ff22a1f2 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -248,7 +248,7 @@ that use taken from lexical scope. The function still can use those from interaction-environment." (quasiquote (let-env-values lips.env.__parent__ (unquote spec) (unquote-splicing body))))(define (apropos name) "(apropos name) Search environment and display names that match the given name. -name can be regex or string." (typecheck "apropos" name (quote ("string" "regex"))) (filter (if (string? name) (new RegExp name) name) (env)))(set-special! "#," (quote sharp-comma))(define **reader-ctor-list** (quote ()))(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**)))))(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...))))))))))(define (promisify fn) "(promisify fn) +name can be regex, string or symbol." (typecheck "apropos" name (quote ("string" "regex" "symbol"))) (let ((regex (lambda (string) (new RegExp (escape-regex string))))) (filter (cond ((string? name) (regex name)) ((symbol? name) (regex (symbol->string name))) (else name)) (env))))(set-special! "#," (quote sharp-comma))(define **reader-ctor-list** (quote ()))(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**)))))(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...))))))))))(define (promisify fn) "(promisify fn) Simple function for adding promises to NodeJS callback based function. Function tested only with fs module." (lambda args (new Promise (lambda (resolve reject) (apply fn (append args (list (lambda (err data) (if (null? err) (resolve data) (reject err))))))))))(define-macro (list* . args) "(list* arg1 ...) diff --git a/dist/std.scm b/dist/std.scm index cf91e458..c64dbc00 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1105,12 +1105,14 @@ "(apropos name) Search environment and display names that match the given name. - name can be regex or string." - (typecheck "apropos" name '("string" "regex")) - (filter (if (string? name) - (new RegExp name) - name) - (env))) + name can be regex, string or symbol." + (typecheck "apropos" name '("string" "regex" "symbol")) + (let ((regex (lambda (string) + (new RegExp (escape-regex string))))) + (filter (cond ((string? name) (regex name)) + ((symbol? name) (regex (symbol->string name))) + (else name)) + (env)))) ;; --------------------------------------------------------------------------------------- ;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 919c96ac..265d1b21 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1105,12 +1105,14 @@ "(apropos name) Search environment and display names that match the given name. - name can be regex or string." - (typecheck "apropos" name '("string" "regex")) - (filter (if (string? name) - (new RegExp name) - name) - (env))) + name can be regex, string or symbol." + (typecheck "apropos" name '("string" "regex" "symbol")) + (let ((regex (lambda (string) + (new RegExp (escape-regex string))))) + (filter (cond ((string? name) (regex name)) + ((symbol? name) (regex (symbol->string name))) + (else name)) + (env)))) ;; --------------------------------------------------------------------------------------- ;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html diff --git a/lib/js/bookmark.js b/lib/js/bookmark.js index 11a6e70b..cba6d5ff 100755 --- a/lib/js/bookmark.js +++ b/lib/js/bookmark.js @@ -40,7 +40,7 @@ javascript:(function(next) { return branch; } } - const REF = await hash('master'); + const REF = await hash('devel'); function track() { /* * this is traking code using Matomo instance, @@ -113,7 +113,7 @@ javascript:(function(next) { track(); } [ - 'https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css', + 'https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@288b8465623fbef62bee1cdf83883ea096711f43/css/jquery.terminal.min.css', 'https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/css/terminal.css', 'https://cdn.jsdelivr.net/gh/jcubic/terminal-prism/css/prism-coy.css' ].forEach(function(url) { diff --git a/src/lips.js b/src/lips.js index 8ed855df..b01ac2b0 100644 --- a/src/lips.js +++ b/src/lips.js @@ -436,6 +436,9 @@ } else { re = LNumber(0); } + if (im.cmp(0) === 0) { + return re; + } return LComplex({ im, re }); } // ---------------------------------------------------------------------- @@ -568,14 +571,12 @@ // ---------------------------------------------------------------------- var string_re = /"(?:\\[\S\s]|[^"])*"?/g; // ---------------------------------------------------------------------- - /* function escape_regex(str) { if (typeof str === 'string') { var special = /([-\\^$[\]()+{}?*.|])/g; return str.replace(special, '\\$1'); } } - */ // ---------------------------------------------------------------------- // Stack used in balanced function // TODO: use it in parser @@ -7491,9 +7492,18 @@ Function return string LIPS representation of an object as string.`), // ------------------------------------------------------------------ + 'escape-regex': doc('escape-regex', function(string) { + typecheck('escape-regex', string, 'string'); + return escape_regex(string.valueOf()); + }, `(escape-regex string) + + Function return new string where all special operators used in regex, + are escaped with slash so they can be used in RegExp constructor + to match literal string`), + // ------------------------------------------------------------------ env: doc(function env(env) { env = env || this; - var names = Object.keys(env.__env__); + var names = Object.keys(env.__env__).map(LSymbol); // TODO: get symbols var result; if (names.length) { @@ -7509,7 +7519,7 @@ (env obj) Function return list of values (functions, macros and variables) - inside environment.`), + inside environment and it's parents.`), // ------------------------------------------------------------------ 'new': doc('new', function(obj, ...args) { var instance = new (unbind(obj))(...args.map(x => unbox(x))); diff --git a/tests/numbers.scm b/tests/numbers.scm index e0d6639b..4a8b171b 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -236,6 +236,10 @@ (test "numbers: complex" (lambda (t) + (t.is 10+0i 10) + (t.is 10+0.0i 10) + (t.is 10.0+0.0i 10.0) + (t.is 1/2+0i 1/2) (t.is (sqrt -1) +1.0i) (t.is (sqrt 0.5) 0.7071067811865476) (t.is (sqrt -0.5) +0.7071067811865476i) @@ -430,3 +434,23 @@ (t.snapshot (! 10)) (t.snapshot (--> (! 8000) (toString))))) + +(test "numbers: positive?" + (lambda (t) + (t.is (positive? 10) #t) + (t.is (positive? 1/2) #t) + (t.is (positive? 0.5) #t) + + (t.is (positive? -10) #f) + (t.is (positive? -1/2) #f) + (t.is (positive? -0.5) #f))) + +(test "numbers: negative?" + (lambda (t) + (t.is (negative? 10) #f) + (t.is (negative? 1/2) #f) + (t.is (negative? 0.5) #f) + + (t.is (negative? -10) #t) + (t.is (negative? -1/2) #t) + (t.is (negative? -0.5) #t))) From b284040c55768a702b1e17ecc309810edaf74535 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Feb 2021 14:31:34 +0100 Subject: [PATCH 011/109] refactor internal variables + docs strings * add doc strings for `**interaction-environment**` and `**internal-env**` --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 32 ++++++++++++++++++++++---------- dist/lips.min.js | 4 ++-- src/lips.js | 36 ++++++++++++++++++++++++++++++------ tests/parser.scm | 5 +++-- tests/test.js | 2 +- 7 files changed, 61 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8672d56b..c64db22d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * add `define-record-type` * add `escape-regex` function * make `apropos` accept symbol as argument +* add doc strings for `**interaction-environment**` and `**internal-env**` ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/README.md b/README.md index cdc1e046..0e6591b5 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&a9403215b546397950a08fa0503b71440c480b64)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&af78f435cce019a2635ef216e055bb63)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&3cb351e69b8823be001123c797345a1c95d93566)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&8e75e2d33163f6516a503d7944596afb)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 98721729..ed0ee23e 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 11:28:22 +0000 + * build: Sun, 14 Feb 2021 13:17:49 +0000 */ (function () { 'use strict'; @@ -8837,8 +8837,7 @@ inter.set('stdout', stdout); } - this.constant('**internal-env**', inter); - global_env.set('**interaction-environment**', this.__env__); + set_interaction_env(this.__env__, inter); } // ------------------------------------------------------------------------- @@ -8938,6 +8937,7 @@ Environment.prototype.doc = function (name) { var value = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : null; + var dump = arguments.length > 2 && arguments[2] !== undefined$1 ? arguments[2] : false; if (name instanceof LSymbol) { name = name.__name__; @@ -8948,6 +8948,10 @@ } if (value) { + if (!dump) { + value = trim_lines(value); + } + this.__docs__.set(name, value); return this; @@ -10160,7 +10164,7 @@ __doc__ = code.cdr.cdr.car.valueOf(); } - env.set(code.car, value, __doc__); + env.set(code.car, value, __doc__, 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))`"), // ------------------------------------------------------------------ @@ -11879,9 +11883,17 @@ return !value; }, "(not object)\n\n Function return negation of the argument.") }, undefined$1, 'global'); - var user_env = global_env.inherit('user-env'); - global_env.set('**interaction-environment**', user_env); - global_env.constant('**internal-env**', internal_env); // ------------------------------------------------------------------------- + var user_env = global_env.inherit('user-env'); // ------------------------------------------------------------------------- + + function set_interaction_env(interaction, internal) { + interaction.constant('**internal-env**', internal); + interaction.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**', interaction); + } // ------------------------------------------------------------------------- + + + 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 map = { @@ -13054,10 +13066,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 14 Feb 2021 11:28:22 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 14 Feb 2021 13:17:49 +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('Sun, 14 Feb 2021 11:28:22 +0000').valueOf(); + var date = LString('Sun, 14 Feb 2021 13:17:49 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13094,7 +13106,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 14 Feb 2021 11:28:22 +0000', + date: 'Sun, 14 Feb 2021 13:17:49 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 28fafcfb..a12852f4 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 11:28:22 +0000 + * build: Sun, 14 Feb 2021 13:17:49 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}if(is_port(i)){o.set("stdout",i)}this.constant("**internal-env**",o);global_env.set("**interaction-environment**",this.__env__)}Interpreter.prototype.exec=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;var n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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;if(e instanceof LSymbol){e=e.__name__}if(e instanceof LString){e=e.valueOf()}if(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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.car,e,r)})}),"(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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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");global_env.set("**interaction-environment**",user_env);global_env.constant("**internal-env**",internal_env);(function(){var e={ceil:"ceiling"};["floor","round","ceil"].forEach(function(r){var n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 11:28:22 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 11:28:22 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 13:17:49 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 13:17:49 +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,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/src/lips.js b/src/lips.js index b01ac2b0..2f297f4f 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5583,8 +5583,7 @@ if (is_port(stdout)) { inter.set('stdout', stdout); } - this.constant('**internal-env**', inter); - global_env.set('**interaction-environment**', this.__env__); + set_interaction_env(this.__env__, inter); } // ------------------------------------------------------------------------- Interpreter.prototype.exec = function(code, dynamic = false, env = null) { @@ -5660,7 +5659,7 @@ // ------------------------------------------------------------------------- // :: lookup function for variable doc strings // ------------------------------------------------------------------------- - Environment.prototype.doc = function(name, value = null) { + Environment.prototype.doc = function(name, value = null, dump = false) { if (name instanceof LSymbol) { name = name.__name__; } @@ -5668,6 +5667,9 @@ name = name.valueOf(); } if (value) { + if (!dump) { + value = trim_lines(value); + } this.__docs__.set(name, value); return this; } @@ -6607,7 +6609,7 @@ LString.isString(code.cdr.cdr.car)) { __doc__ = code.cdr.cdr.car.valueOf(); } - env.set(code.car, value, __doc__); + env.set(code.car, value, __doc__, true); }); }), `(define name expression) (define (function-name . args) body) @@ -8346,8 +8348,30 @@ Function return negation of the argument.`) }, undefined, 'global'); var user_env = global_env.inherit('user-env'); - global_env.set('**interaction-environment**', user_env); - global_env.constant('**internal-env**', internal_env); + // ------------------------------------------------------------------------- + function set_interaction_env(interaction, internal) { + interaction.constant('**internal-env**', internal); + interaction.doc( + '**internal-env**', + `**internal-env** + + Constant used to hide stdin, stdout and stderr so they don't interfere + with variables with the same name. Constants are internal type + of variables that can't be redefined, defining variable with same name + will throw an error.` + ); + global_env.set('**interaction-environment**', interaction); + } + // ------------------------------------------------------------------------- + set_interaction_env(user_env, internal_env); + global_env.doc( + '**interaction-environment**', + `**interaction-environment** + + Internal dynamic, global variable used to find interpreter environment. + It's used so the read and write functions can locate **internal-env** + that contain references to stdin, stdout and stderr.` + ); // ------------------------------------------------------------------------- (function() { var map = { ceil: 'ceiling' }; diff --git a/tests/parser.scm b/tests/parser.scm index 2501ab51..f8174ff5 100644 --- a/tests/parser.scm +++ b/tests/parser.scm @@ -1,7 +1,8 @@ (set-special! "<>" 'html lips.specials.SPLICE) + (define-macro (html . args) - (let ((str (--> (list->array (map symbol->string args)) (join "+")))) - `(string-append "<" ,str "/>"))) + (let ((str (--> (list->array (map symbol->string args)) (join "+")))) + `(string-append "<" ,str "/>"))) (define parser/t1 <>(foo bar)) diff --git a/tests/test.js b/tests/test.js index 7aaa003a..43451829 100644 --- a/tests/test.js +++ b/tests/test.js @@ -36,7 +36,7 @@ get_files().then(filenames => { })).then(async function (files) { await lips.exec(` (let-env lips.env.__parent__ - (load "./dist/std.scm") + (load "./dist/std.min.scm") (load "./tests/helpers/helpers.scm")) `); return lips.exec([` From fe66d00d2053f8d3f75b3f6fe5024054081c2c3e Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Feb 2021 15:08:24 +0100 Subject: [PATCH 012/109] add `letrec*` macro --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 10 ++++++---- dist/lips.min.js | 4 ++-- src/lips.js | 8 ++++++++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c64db22d..e729435b 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * add `escape-regex` function * make `apropos` accept symbol as argument * add doc strings for `**interaction-environment**` and `**internal-env**` +* add `letrec*` that in LIPS is exactly the same as `letrec` ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/README.md b/README.md index 0e6591b5..5b2eaa24 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&3cb351e69b8823be001123c797345a1c95d93566)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&8e75e2d33163f6516a503d7944596afb)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&b284040c55768a702b1e17ecc309810edaf74535)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index ed0ee23e..e72ec7c9 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 13:17:49 +0000 + * build: Sun, 14 Feb 2021 14:08:11 +0000 */ (function () { 'use strict'; @@ -10071,6 +10071,8 @@ // ------------------------------------------------------------------ '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."), @@ -13066,10 +13068,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 14 Feb 2021 13:17:49 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 14 Feb 2021 14:08:11 +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('Sun, 14 Feb 2021 13:17:49 +0000').valueOf(); + var date = LString('Sun, 14 Feb 2021 14:08:11 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13106,7 +13108,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 14 Feb 2021 13:17:49 +0000', + date: 'Sun, 14 Feb 2021 14:08:11 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index a12852f4..e6ff2e90 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 13:17:49 +0000 + * build: Sun, 14 Feb 2021 14:08:11 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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."),"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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 13:17:49 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 13:17:49 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var p="suspendedStart";var _="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=p;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw n}return P()}c.method=r;c.arg=n;while(true){var t=c.delegate;if(t){var i=A(t,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===p){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:_;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var t=f(n,e.iterator,r.arg);if(t.type==="throw"){r.method="throw";r.arg=t.arg;r.delegate=null;return m}var i=t.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(_.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var p=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(p))}}}]);return _}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var p=l[f];if(p.token.trim()){return p.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),c;try{for(o.s();!(c=o.n()).done;){var s=slicedToArray(c.value,3),l=s[0],f=s[1],p=s[2];f=f.valueOf();var _=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(_&&(p instanceof Ahead&&p.match(h)||!p)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name,">")}else{return"#<procedure>"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return(t=e).toString.apply(t,[r].concat(a))}if(Number.isNaN(e)){return"+nan.0"}if(e instanceof LCharacter){if(r){return e.toString()}return e.valueOf()}if([nil,eof].includes(e)){return e.toString()}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if(e instanceof RegExp){return"#"+e.toString()}if(is_function(e)){return function_to_string(e)}if(e instanceof LString){e=e.toString();if(r){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var _=user_repr(e);if(_){if(is_function(_)){return _(e,r)}else{throw new Error("toString: Invalid repr value")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#<iterator(".concat(p,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#<asyncIterator(".concat(p,")>")}return"#<asyncIterator>"}if(p!==""){return"#<"+p+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",d(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",d(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,t,i);case 30:f=r.sent;case 31:p=n.cdr;if(!(p instanceof Pair)){r.next=36;break}r.next=35;return d(p,t,i);case 35:p=r.sent;case 36:_=new Pair(f,p);return r.abrupt("return",_);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(_)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return _()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+p+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}if(Array.from(e).length>1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.value)){r=this.value.pow(e.value)}else{r=pow(this.value,e.value)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.value;if(LNumber.isNative(this.value)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.value)){if(this.isBigNumber()){return this.value%BigInt(2)===BigInt(1)}return this.value%2===1}else if(LNumber.isBN(this.value)){return this.value.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.value<r.value){return-1}else if(e.value===r.value){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.value)){return a(t,i)}else if(LNumber.isBN(t.value)){return this.value.cmp(i.value)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/});var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:NaN,"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(p){p=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:p,error:_})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var p=extract_patterns(l,e,s,o,{expansion:this,define:g});if(p){if(is_debug()){console.log(JSON.stringify(symbolize(p),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var _=[];var h=transform_syntax({bindings:p,expr:f,symbols:s,scope:t,lex_scope:i,names:_,ellipsis:o});if(h){f=h}var d=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,_)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=d(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(d(r,t,i));return e},[])}function p(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=d(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function _(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),d(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){var r=arguments.length,n=abs(arguments.length<=0?undefined$1:arguments[0]);for(var t=1;t<r;t++){var i=abs(t<0||arguments.length<=t?undefined$1:arguments[t]),a=n;while(n&&i){n>i?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===1},r)},"(> x1 x2 x3 ...)\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),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return LNumber(e).cmp(r)===-1},r)},"(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,-1].includes(LNumber(e).cmp(r))},r)},"(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return seq_compare(function(e,r){return[0,1].includes(LNumber(e).cmp(r))},r)},"(>= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}if(is_function(e)&&e[Symbol["for"]("promise")]){return"promise"}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 14:08:11 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 14:08:11 +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,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/src/lips.js b/src/lips.js index 2f297f4f..41ef4692 100644 --- a/src/lips.js +++ b/src/lips.js @@ -6490,6 +6490,14 @@ Values are evaluated sequentialy and next value can access to previous values/names.`), // --------------------------------------------------------------------- + 'letrec*': doc( + let_macro(Symbol.for('letrec')), + `(letrec* ((a value-a) (b value-b)) body) + + Same as letrec but the order of execution of the binding is guaranteed, + so use can use recursive code as well as reference previous binding. + In LIPS both letrec and letrec* behave the same.`), + // --------------------------------------------------------------------- 'let*': doc( let_macro(Symbol.for('let*')), `(let* ((a value-a) (b value-b)) body) From 848302ee2f484d3fab4ebe73d4b21c4d20077f90 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Feb 2021 15:39:02 +0100 Subject: [PATCH 013/109] remove debug code from bookmark --- lib/js/bookmark.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/js/bookmark.js b/lib/js/bookmark.js index cba6d5ff..ef665575 100755 --- a/lib/js/bookmark.js +++ b/lib/js/bookmark.js @@ -40,7 +40,7 @@ javascript:(function(next) { return branch; } } - const REF = await hash('devel'); + const REF = await hash('master'); function track() { /* * this is traking code using Matomo instance, @@ -113,7 +113,7 @@ javascript:(function(next) { track(); } [ - 'https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@288b8465623fbef62bee1cdf83883ea096711f43/css/jquery.terminal.min.css', + 'https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal/css/jquery.terminal.min.css', 'https://cdn.jsdelivr.net/gh/jcubic/lips@devel/lib/css/terminal.css', 'https://cdn.jsdelivr.net/gh/jcubic/terminal-prism/css/prism-coy.css' ].forEach(function(url) { From db7e16c614c1dd893b54eec885d7030b59b9b49f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 15 Feb 2021 14:16:01 +0100 Subject: [PATCH 014/109] fix typechecking of number operators + fix err messages #128 --- CHANGELOG.md | 1 + README.md | 4 ++-- src/lips.js | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e729435b..653061c0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string * fix escaping regex operators when using string with `apropos` +* fix typechecking of number operators [#128](https://github.com/jcubic/lips/issues/128) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index c001d4e6..04bbd953 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&b284040c55768a702b1e17ecc309810edaf74535)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&6809e11cefbc823b4f33eba86c1c32670af0181d)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ef48bcf267790da8598dfe6d127818eb)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/src/lips.js b/src/lips.js index 41ef4692..3803c734 100644 --- a/src/lips.js +++ b/src/lips.js @@ -8078,7 +8078,11 @@ (define add1 (curry add 1)) (define add12 (add 2)) (display (add12 3 4))`), + // ------------------------------------------------------------------ + // Numbers + // ------------------------------------------------------------------ 'gcd': doc(function gcd(...args) { + typecheck_args('lcm', args, 'number'); return args.reduce(function(result, item) { return result.gcd(item); }); @@ -8087,6 +8091,7 @@ Function return the greatest common divisor of their arguments.`), // ------------------------------------------------------------------ 'lcm': doc(function lcm(...args) { + typecheck_args('lcm', args, 'number'); // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript var n = args.length, a = abs(args[0]); for (var i = 1; i < n; i++) { @@ -8132,6 +8137,7 @@ if (args.length === 0) { throw new Error('-: procedure require at least one argument'); } + typecheck_args('-', args, 'number'); if (args.length === 1) { return LNumber(args[0]).sub(); } @@ -8160,6 +8166,7 @@ Function create absolute value from number.`), // ------------------------------------------------------------------ truncate: doc('truncate', function(n) { + typecheck('truncate', n, 'number'); if (LNumber.isFloat(n)) { if (n instanceof LNumber) { n = n.valueOf(); @@ -8201,6 +8208,7 @@ Function substract 1 from the number and return result.`), // ------------------------------------------------------------------ '%': doc('%', function(a, b) { + typecheck_args('%', [a, b], 'number'); return LNumber(a).rem(b); }, `(% n1 n2) @@ -8208,35 +8216,40 @@ // ------------------------------------------------------------------ // Booleans '==': doc('==', function(...args) { + typecheck_args('==', args, 'number'); return seq_compare((a, b) => LNumber(a).cmp(b) === 0, args); - }, `(== x1 x2 x3 ...) + }, `(== x1 x2 ...) Function compare its numerical arguments and check if they are equal`), // ------------------------------------------------------------------ '>': doc('>', function(...args) { + typecheck_args('>', args, 'number'); return seq_compare((a, b) => LNumber(a).cmp(b) === 1, args); - }, `(> x1 x2 x3 ...) + }, `(> x1 x2 ...) Function compare its numerical arguments and check if they are monotonically increasing`), // ------------------------------------------------------------------ '<': doc('<', function(...args) { + typecheck_args('<', args, 'number'); return seq_compare((a, b) => LNumber(a).cmp(b) === -1, args); - }, `(< x1 x2 x3 ...) + }, `(< x1 x2 ...) Function compare its numerical arguments and check if they are monotonically decreasing`), // ------------------------------------------------------------------ '<=': doc(function(...args) { + typecheck_args('<=', args, 'number'); return seq_compare((a, b) => [0, -1].includes(LNumber(a).cmp(b)), args); - }, `(<= x1 x2 x3 ...) + }, `(<= x1 x2 ...) Function compare its numerical arguments and check if they are monotonically nonincreasing`), // ------------------------------------------------------------------ '>=': doc('>=', function(...args) { + typecheck_args('>=', args, 'number'); return seq_compare((a, b) => [0, 1].includes(LNumber(a).cmp(b)), args); - }, `(>= x1 x2 x3 ...) + }, `(>= x1 x2 ...) Function compare its numerical arguments and check if they are monotonically nondecreasing`), @@ -8540,6 +8553,12 @@ return `Expecting ${expected}, got ${got}${postfix}`; } // ------------------------------------------------------------------------- + function typecheck_args(fn, args, expected) { + args.forEach((arg, i) => { + typecheck(fn, arg, expected, i + 1); + }); + } + // ------------------------------------------------------------------------- function typecheck(fn, arg, expected, position = null) { fn = fn.valueOf(); const arg_type = type(arg).toLowerCase(); @@ -8912,8 +8931,13 @@ dynamic_scope, error: (e, code) => { if (e && e.message) { - // clean duplicated Error: added by JS - e.message = e.message.replace(/.*:\s*([^:]+:\s*)/, '$1'); + if (e.message.match(/^Error:/)) { + // clean duplicated Error: added by JS + e.message = e.message.replace(/.*:\s*([^:]+:\s*)/, '$1'); + } else { + // add missing Error + e.message = `Error: ${e.message}`; + } if (code) { // LIPS stack trace if (!(e.__code__ instanceof Array)) { From 49dc276233817799429810e6482305815d3a0f46 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 15 Feb 2021 16:53:25 +0100 Subject: [PATCH 015/109] remove hyperapp example --- examples/app.scm | 50 ------------- examples/common.css | 49 ------------ examples/hyper.html | 19 ----- examples/index.html | 178 -------------------------------------------- 4 files changed, 296 deletions(-) delete mode 100644 examples/app.scm delete mode 100644 examples/common.css delete mode 100644 examples/hyper.html delete mode 100644 examples/index.html diff --git a/examples/app.scm b/examples/app.scm deleted file mode 100644 index 3e8d85bf..00000000 --- a/examples/app.scm +++ /dev/null @@ -1,50 +0,0 @@ -;; -*- scheme -*- -;; This is example hyperapp application written in LIPS -;; -;; This file is part of the LIPS - Scheme implementation in JavaScript -;; Copyriht (C) 2019-2020 Jakub T. Jankiewicz <https://jcubic.pl> -;; Released under MIT license -;; - -(define h (.. hyperapp.h)) -(define app (.. hyperapp.app)) - -;; helper for this specific app - hyperapp action generator that create new state - -(define (update fn) - "(update fn) - - Function create new action that create new state with updated alist value - that is returned from function." - (lambda (value) - (lambda (state) - (let* ((alist (. state "counter")) - (old (cdr (assoc 'count alist)))) - (make-object :counter (alist->assign '() alist `((count . ,(fn old value))))))))) - - -;; ----------------------------------------------------------------------------- -;; MAIN APPLICATION CODE -;; ----------------------------------------------------------------------------- - -;; Hyper app actions -(define actions (make-object :up (update +) - :down (update -))) - - -;; inital state -(define state (make-object :counter '((count . 0)))) - -(define (Counter obj) - (with-tags (:h1 () (concat "Counter: " (. obj 'count))))) - -(define (view state actions) - "hyperapp view" - (let ((counter (. state "counter"))) - (with-tags (:div () - (list (Counter (:count (cdr (assoc 'count counter)))) - (:button (:onclick (lambda () (--> actions (down 1)))) "-") - (:button (:onclick (lambda () (--> actions (up 1)))) "+")))))) - -;; main hyper app -(define main (app state actions view (--> document (querySelector "#app")))) diff --git a/examples/common.css b/examples/common.css deleted file mode 100644 index 9a429aa6..00000000 --- a/examples/common.css +++ /dev/null @@ -1,49 +0,0 @@ -.tabs .panels > :not(.active) { - display: none; -} -.tabs ul { - list-style: none; - padding: 0; - margin: 0; - overflow: hidden; -} -.tabs .panels { - clear: both; -} -.tabs li { - display: block; - float: left; - position: relative; - border-radius: 10px 10px 0 0; -} -.tabs li:hover { -/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#e5e5e5+0,ffffff+100 */ -background: #e5e5e5; /* Old browsers */ -background: -moz-linear-gradient(-45deg, #e5e5e5 0%, #ffffff 100%); /* FF3.6-15 */ -background: -webkit-linear-gradient(-45deg, #e5e5e5 0%,#ffffff 100%); /* Chrome10-25,Safari5.1-6 */ -background: linear-gradient(135deg, #e5e5e5 0%,#ffffff 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ -filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#ffffff',GradientType=1 ); /* IE6-9 fallback on horizontal gradient */ -} -.tabs li.active:after { - content: ''; - display: block; - border-bottom: 5px solid #295ee5; - position: absolute; - width: 100%; - bottom: 0; -} -.tabs li a { - text-decoration: none; - padding: 10px; - display: inline-block; - border: 1px solid black; - border-radius: 10px 10px 0 0; - border-bottom: none; -} -.tabs li + li a { - border-left: none; -} -code[class*="language-"], pre[class*="language-"] { - white-space: pre-wrap; - word-break: break-word; -} diff --git a/examples/hyper.html b/examples/hyper.html deleted file mode 100644 index fcbbf68a..00000000 --- a/examples/hyper.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE HTML> -<html xmlns="http://www.w3.org/1999/xhtml"> -<head> - <meta charset="utf-8" /> - <title>Demo LIPS Hyperapp app - - - - - - - -
- - - - diff --git a/examples/index.html b/examples/index.html deleted file mode 100644 index e64a3d84..00000000 --- a/examples/index.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - - HyperApp LIPS Demo - - - - - - - - - - - - - - - - - - - - - - -
-

Hyperapp LIPS demo

-
- -
-
-

README

-

- This is example applictation using Hyperapp - together with LIPS interpter. Main application code is in app.lips file. The - rest of the files are just helper macros and functions. -

-

This demo

-

- This page is created using jQuery code and in JavaScript but the hyper app is created using only - LIPS code. It's inserted into iframe. Terminal on this is page can interact with lips instance - from iframe.

-

Playing with terminal

-

You can execute example codes:

-

-;; this will call up method on main app object
-;; --> is macro defined in helpers.lips
-(--> main (up 10))
-      
-

Hyperapp

-

LIPS code for the hyperapp is based on example from readme. I've used direct calls of h function in form:

-

-import { h } from "hyperapp"
-
-export const view = (state, actions) =>
-  h("div", {}, [
-    h("h1", {}, state.count),
-    h("button", { onclick: () => actions.down(1) }, "-"),
-    h("button", { onclick: () => actions.up(1) }, "+")
-  ])
-      
-
-
-
-
    -
    -
    -
    -
    -
    -
    - - From ba15ae832b8c11271733c7e296c57d9908b99fdb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Feb 2021 16:56:07 +0100 Subject: [PATCH 016/109] update preact example --- examples/preact.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/preact.html b/examples/preact.html index 93738ea9..d8c12303 100644 --- a/examples/preact.html +++ b/examples/preact.html @@ -8,8 +8,8 @@ - - + + From b8a079740ba1411751f6d27eea4aa5d9bf66d5c7 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Feb 2021 16:56:38 +0100 Subject: [PATCH 017/109] allow to run scheme-detect as shell script --- examples/scheme-detect.scm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/scheme-detect.scm b/examples/scheme-detect.scm index 44ee8ab6..3503b6ee 100755 --- a/examples/scheme-detect.scm +++ b/examples/scheme-detect.scm @@ -91,3 +91,7 @@ (and (not memo) (set! memo (detect:match-signature))) memo))) + +(if (and (not (null? (. self 'process)) + (= process.argv.length 4)) + (print (detect:name))) From af81691d0430abab485b285ebeb1f85730edc25b Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Feb 2021 16:59:26 +0100 Subject: [PATCH 018/109] add `pragma->sxml` macro that define `sxml` macro (default is `h`) --- CHANGELOG.md | 1 + dist/std.min.scm | 8 ++++---- dist/std.scm | 22 +++++++++++++--------- lib/bootstrap.scm | 22 +++++++++++++--------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 653061c0..870742c9 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * make `apropos` accept symbol as argument * add doc strings for `**interaction-environment**` and `**internal-env**` * add `letrec*` that in LIPS is exactly the same as `letrec` +* add `pragma->sxml` macro that define `sxml` macro (default is `h`) ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/dist/std.min.scm b/dist/std.min.scm index ff22a1f2..ef5d9427 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -182,15 +182,15 @@ Macro allow to create anonymous classes. See define-class for details.")(define Function that return list structure of code with better syntax then raw LIPS" (quasiquote (h (unquote (let ((val (car expr))) (if (key? val) (key->string val) val))) (alist->object ((unquote (quote quasiquote)) (unquote (pair-map (lambda (car cdr) (quasiquote ((unquote (key->string car)) (unquote (quote unquote)) (unquote cdr)))) (cadr expr))))) (unquote (if (not (null? (cddr expr))) (if (and (pair? (caddr expr)) (let ((s (caaddr expr))) (and (symbol? s) (eq? s (quote list))))) (quasiquote (list->array (list (unquote-splicing (map make-tags (cdaddr expr)))))) (caddr expr)))))))(define (%sxml h expr) "(%sxml h expr) -Helper function that render expression using create element function." (let* ((have-attrs (and (not (null? (cdr expr))) (pair? (cadr expr)) (eq? (caadr expr) (quote @)))) (attrs (if have-attrs (cdadr expr) ())) (rest (if have-attrs (cddr expr) (cdr expr)))) (quasiquote ((unquote h) (unquote (let* ((symbol (car expr)) (name (symbol->string symbol))) (if (char-lower-case? (car (string->list name))) name symbol))) (alist->object ((unquote (quote quasiquote)) (unquote (map (lambda (pair) (cons (symbol->string (car pair)) (list (quote unquote) (cadr pair)))) attrs)))) (unquote-splicing (if (null? rest) () (let ((first (car rest))) (if (pair? first) (map (lambda (expr) (%sxml h expr)) rest) (list first)))))))))(define-macro (sxml expr) "(sxml expr) +Helper function that render expression using create element function." (let* ((have-attrs (and (not (null? (cdr expr))) (pair? (cadr expr)) (eq? (caadr expr) (quote @)))) (attrs (if have-attrs (cdadr expr) ())) (rest (if have-attrs (cddr expr) (cdr expr)))) (quasiquote ((unquote h) (unquote (let* ((symbol (car expr)) (name (symbol->string symbol))) (if (char-lower-case? (car (string->list name))) name symbol))) (alist->object ((unquote (quote quasiquote)) (unquote (map (lambda (pair) (cons (symbol->string (car pair)) (list (quote unquote) (cadr pair)))) attrs)))) (unquote-splicing (if (null? rest) () (let ((first (car rest))) (if (pair? first) (map (lambda (expr) (%sxml h expr)) rest) (list first)))))))))(define-macro (pragma->sxml pragma) (quasiquote (define-macro (sxml expr) "(sxml expr) Macro for JSX like syntax but with SXML. e.g. usage: (sxml (div (@ (data-foo \"hello\") - (id \"foo\")) - (span \"hello\") - (span \"world\")))" (%sxml (quote h) expr))(define-macro (with-tags expr) "(with-tags expression) + (id \"foo\")) + (span \"hello\") + (span \"world\")))" (%sxml (quote (unquote pragma)) expr))))(pragma->sxml h)(define-macro (with-tags expr) "(with-tags expression) Macro that evalute LIPS shorter code for S-Expression equivalent of JSX. e.g.: diff --git a/dist/std.scm b/dist/std.scm index c64dbc00..d375c6bb 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -862,17 +862,21 @@ (list first))))))) ;; --------------------------------------------------------------------------------------- -(define-macro (sxml expr) - "(sxml expr) +(define-macro (pragma->sxml pragma) + `(define-macro (sxml expr) + "(sxml expr) - Macro for JSX like syntax but with SXML. - e.g. usage: + Macro for JSX like syntax but with SXML. + e.g. usage: - (sxml (div (@ (data-foo \"hello\") - (id \"foo\")) - (span \"hello\") - (span \"world\")))" - (%sxml 'h expr)) + (sxml (div (@ (data-foo \"hello\") + (id \"foo\")) + (span \"hello\") + (span \"world\")))" + (%sxml ',pragma expr))) + +;; --------------------------------------------------------------------------------------- +(pragma->sxml h) ;; --------------------------------------------------------------------------------------- (define-macro (with-tags expr) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 265d1b21..6d09756c 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -862,17 +862,21 @@ (list first))))))) ;; --------------------------------------------------------------------------------------- -(define-macro (sxml expr) - "(sxml expr) +(define-macro (pragma->sxml pragma) + `(define-macro (sxml expr) + "(sxml expr) - Macro for JSX like syntax but with SXML. - e.g. usage: + Macro for JSX like syntax but with SXML. + e.g. usage: - (sxml (div (@ (data-foo \"hello\") - (id \"foo\")) - (span \"hello\") - (span \"world\")))" - (%sxml 'h expr)) + (sxml (div (@ (data-foo \"hello\") + (id \"foo\")) + (span \"hello\") + (span \"world\")))" + (%sxml ',pragma expr))) + +;; --------------------------------------------------------------------------------------- +(pragma->sxml h) ;; --------------------------------------------------------------------------------------- (define-macro (with-tags expr) From 2d66b4e25c0341987fe722465b5ff7eb1745d4ef Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Mon, 15 Feb 2021 18:02:22 +0100 Subject: [PATCH 019/109] add script scheme-detect that use example --- examples/scheme-detect.scm | 4 ---- scripts/scheme-detect.scm | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100755 scripts/scheme-detect.scm diff --git a/examples/scheme-detect.scm b/examples/scheme-detect.scm index 3503b6ee..44ee8ab6 100755 --- a/examples/scheme-detect.scm +++ b/examples/scheme-detect.scm @@ -91,7 +91,3 @@ (and (not memo) (set! memo (detect:match-signature))) memo))) - -(if (and (not (null? (. self 'process)) - (= process.argv.length 4)) - (print (detect:name))) diff --git a/scripts/scheme-detect.scm b/scripts/scheme-detect.scm new file mode 100755 index 00000000..cb8ad7f1 --- /dev/null +++ b/scripts/scheme-detect.scm @@ -0,0 +1,5 @@ +#!/usr/bin/env lips + +(load "../examples/scheme-detect.scm") + +(print (detect:name)) From 9cf9597022fddbf33247f3fc6133c5869ed66a8a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 12:31:44 +0100 Subject: [PATCH 020/109] fix repr and type of quoted promises (breaking) --- CHANGELOG.md | 1 + README.md | 4 +- dist/lips.js | 111 +++++++++++++++++++++++++++++++---------------- dist/lips.min.js | 4 +- src/lips.js | 10 +++-- 5 files changed, 85 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 870742c9..9af5f248 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.0.0-beta.12 ### Breaking * `env` now return symbols instead of strings +* repr and type of quoted promises that show `#` and `promise` ### Features * create minfied std scheme file for faster bootstrap * add `list-copy` diff --git a/README.md b/README.md index 04bbd953..4a190939 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&6809e11cefbc823b4f33eba86c1c32670af0181d)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ef48bcf267790da8598dfe6d127818eb)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&2d66b4e25c0341987fe722465b5ff7eb1745d4ef)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index e72ec7c9..434caedf 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 14:08:11 +0000 + * build: Tue, 16 Feb 2021 11:31:03 +0000 */ (function () { 'use strict'; @@ -2195,6 +2195,11 @@ QuotedPromise.prototype.valueOf = function () { return this.__promise__; }; // ---------------------------------------------------------------------- + + + QuotedPromise.prototype.toString = function () { + return '#'; + }; // ---------------------------------------------------------------------- // :: Parser macros transformers // ---------------------------------------------------------------------- @@ -11605,30 +11610,39 @@ 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))"), + // ------------------------------------------------------------------ + // Numbers + // ------------------------------------------------------------------ 'gcd': doc(function gcd() { for (var _len33 = arguments.length, args = new Array(_len33), _key34 = 0; _key34 < _len33; _key34++) { args[_key34] = arguments[_key34]; } + typecheck_args('lcm', args, 'number'); return args.reduce(function (result, item) { return result.gcd(item); }); }, "(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."), // ------------------------------------------------------------------ 'lcm': doc(function lcm() { - // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript - var n = arguments.length, - a = abs(arguments.length <= 0 ? undefined$1 : arguments[0]); + for (var _len34 = arguments.length, args = new Array(_len34), _key35 = 0; _key35 < _len34; _key35++) { + args[_key35] = arguments[_key35]; + } + + typecheck_args('lcm', args, 'number'); // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript + + var n = args.length, + a = abs(args[0]); for (var i = 1; i < n; i++) { - var b = abs(i < 0 || arguments.length <= i ? undefined$1 : arguments[i]), + var b = abs(args[i]), c = a; while (a && b) { a > b ? a %= b : b %= a; } - a = abs(c * (i < 0 || arguments.length <= i ? undefined$1 : arguments[i])) / (a + b); + a = abs(c * args[i]) / (a + b); } return LNumber(a); @@ -11652,14 +11666,16 @@ }, 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 _len34 = arguments.length, args = new Array(_len34), _key35 = 0; _key35 < _len34; _key35++) { - args[_key35] = arguments[_key35]; + for (var _len35 = arguments.length, args = new Array(_len35), _key36 = 0; _key36 < _len35; _key36++) { + args[_key36] = arguments[_key36]; } if (args.length === 0) { throw new Error('-: procedure require at least one argument'); } + typecheck_args('-', args, 'number'); + if (args.length === 1) { return LNumber(args[0]).sub(); } @@ -11680,6 +11696,8 @@ }), "(abs number)\n\n Function create absolute value from number."), // ------------------------------------------------------------------ truncate: doc('truncate', function (n) { + typecheck('truncate', n, 'number'); + if (LNumber.isFloat(n)) { if (n instanceof LNumber) { n = n.valueOf(); @@ -11715,59 +11733,65 @@ }), "(1- number)\n\n Function substract 1 from the number and return result."), // ------------------------------------------------------------------ '%': doc('%', function (a, b) { + typecheck_args('%', [a, b], 'number'); return LNumber(a).rem(b); }, "(% n1 n2)\n\n Function get reminder of it's arguments."), // ------------------------------------------------------------------ // Booleans '==': doc('==', function () { - for (var _len35 = arguments.length, args = new Array(_len35), _key36 = 0; _key36 < _len35; _key36++) { - args[_key36] = arguments[_key36]; + for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { + args[_key37] = arguments[_key37]; } + typecheck_args('==', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === 0; }, args); - }, "(== x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are equal"), + }, "(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"), // ------------------------------------------------------------------ '>': doc('>', function () { - for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { - args[_key37] = arguments[_key37]; + for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { + args[_key38] = arguments[_key38]; } + typecheck_args('>', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === 1; }, args); - }, "(> x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"), + }, "(> x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"), // ------------------------------------------------------------------ '<': doc('<', function () { - for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { - args[_key38] = arguments[_key38]; + for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { + args[_key39] = arguments[_key39]; } + typecheck_args('<', args, 'number'); return seq_compare(function (a, b) { return LNumber(a).cmp(b) === -1; }, args); - }, "(< x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"), + }, "(< x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"), // ------------------------------------------------------------------ '<=': doc(function () { - for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { - args[_key39] = arguments[_key39]; + for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { + args[_key40] = arguments[_key40]; } + typecheck_args('<=', args, 'number'); return seq_compare(function (a, b) { return [0, -1].includes(LNumber(a).cmp(b)); }, args); - }, "(<= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"), + }, "(<= x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"), // ------------------------------------------------------------------ '>=': doc('>=', function () { - for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { - args[_key40] = arguments[_key40]; + for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { + args[_key41] = arguments[_key41]; } + typecheck_args('>=', args, 'number'); return seq_compare(function (a, b) { return [0, 1].includes(LNumber(a).cmp(b)); }, args); - }, "(>= x1 x2 x3 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nondecreasing"), + }, "(>= 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."), // ------------------------------------------------------------------ @@ -12072,6 +12096,13 @@ } // ------------------------------------------------------------------------- + function typecheck_args(fn, args, expected) { + args.forEach(function (arg, i) { + typecheck(fn, arg, expected, i + 1); + }); + } // ------------------------------------------------------------------------- + + function typecheck(fn, arg, expected) { var position = arguments.length > 3 && arguments[3] !== undefined$1 ? arguments[3] : null; fn = fn.valueOf(); @@ -12165,11 +12196,11 @@ for (var _i5 = 0, _Object$entries2 = Object.entries(mapping); _i5 < _Object$entries2.length; _i5++) { var _Object$entries2$_i = slicedToArray(_Object$entries2[_i5], 2), - _key41 = _Object$entries2$_i[0], + _key42 = _Object$entries2$_i[0], value = _Object$entries2$_i[1]; if (obj instanceof value) { - return _key41; + return _key42; } } @@ -12205,10 +12236,6 @@ } } - if (is_function(obj) && obj[Symbol["for"]('promise')]) { - return 'promise'; - } - return _typeof_1(obj); } // ------------------------------------------------------------------------- // :; wrap tree of Promises with single Promise or return argument as is @@ -12422,8 +12449,8 @@ args = args.map(function (arg) { if (is_lips_function(arg)) { var wrapper = function wrapper() { - for (var _len40 = arguments.length, args = new Array(_len40), _key42 = 0; _key42 < _len40; _key42++) { - args[_key42] = arguments[_key42]; + for (var _len41 = arguments.length, args = new Array(_len41), _key43 = 0; _key43 < _len41; _key43++) { + args[_key43] = arguments[_key43]; } return unpromise(arg.apply(this, args), unbox); @@ -12639,8 +12666,13 @@ dynamic_scope: dynamic_scope, error: function error(e, code) { if (e && e.message) { - // clean duplicated Error: added by JS - e.message = e.message.replace(/.*:\s*([^:]+:\s*)/, '$1'); + if (e.message.match(/^Error:/)) { + // clean duplicated Error: added by JS + e.message = e.message.replace(/.*:\s*([^:]+:\s*)/, '$1'); + } else { + // add missing Error + e.message = "Error: ".concat(e.message); + } if (code) { // LIPS stack trace @@ -13068,10 +13100,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 14 Feb 2021 14:08:11 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Feb 2021 11:31:03 +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('Sun, 14 Feb 2021 14:08:11 +0000').valueOf(); + var date = LString('Tue, 16 Feb 2021 11:31:03 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13099,16 +13131,19 @@ InputPort.__class__ = 'input-port'; OutputPort.__class__ = 'output-port'; OutputStringPort.__class__ = 'output-string-port'; - InputStringPort.__class__ = 'input-string-port'; // types used for detect lips objects + InputStringPort.__class__ = 'input-string-port'; + InputFilePort.__class__ = 'input-file-port'; + OutputFilePort.__class__ = 'output-file-port'; // types used for detect lips objects LNumber.__class__ = 'number'; LCharacter.__class__ = 'character'; - LString.__class__ = 'string'; // ------------------------------------------------------------------------- + LString.__class__ = 'string'; + QuotedPromise.__class__ = 'promise'; // ------------------------------------------------------------------------- var lips = { version: 'DEV', banner: banner, - date: 'Sun, 14 Feb 2021 14:08:11 +0000', + date: 'Tue, 16 Feb 2021 11:31:03 +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 e6ff2e90..34d6f3df 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 14 Feb 2021 14:08:11 +0000 + * build: Tue, 16 Feb 2021 11:31:03 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;ti?n%=i:i%=n}n=abs(a*(t<0||arguments.length<=t?undefined$1:arguments[t]))/(n+i)}return LNumber(n)},"(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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n x1 x2 x3 ...)\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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n= x1 x2 x3 ...)\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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){if(r&&r.message){r.message=r.message.replace(/.*:\s*([^:]+:\s*)/,"$1");if(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 14 Feb 2021 14:08:11 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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";LNumber.__class__="number";LCharacter.__class__="character";LString.__class__="string";var lips={version:"DEV",banner:banner,date:"Sun, 14 Feb 2021 14:08:11 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 11:31:03 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 11:31:03 +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,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/src/lips.js b/src/lips.js index 3803c734..5d819df4 100644 --- a/src/lips.js +++ b/src/lips.js @@ -816,6 +816,10 @@ return this.__promise__; }; // ---------------------------------------------------------------------- + QuotedPromise.prototype.toString = function() { + return '#'; + }; + // ---------------------------------------------------------------------- // :: Parser macros transformers // ---------------------------------------------------------------------- var specials = { @@ -8667,9 +8671,6 @@ return obj.constructor.name.toLowerCase(); } } - if (is_function(obj) && obj[Symbol.for('promise')]) { - return 'promise'; - } return typeof obj; } // ------------------------------------------------------------------------- @@ -9272,10 +9273,13 @@ You can also use (help name) to display help for specic function or macro and OutputPort.__class__ = 'output-port'; OutputStringPort.__class__ = 'output-string-port'; InputStringPort.__class__ = 'input-string-port'; + InputFilePort.__class__ = 'input-file-port'; + OutputFilePort.__class__ = 'output-file-port'; // types used for detect lips objects LNumber.__class__ = 'number'; LCharacter.__class__ = 'character'; LString.__class__ = 'string'; + QuotedPromise.__class__ = 'promise'; // ------------------------------------------------------------------------- var lips = { version: '{{VER}}', From b6dbf797a464e9dec097e32de14ce345e4d79aab Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 15:51:00 +0100 Subject: [PATCH 021/109] fix indent of call-with- (input-file, output-file and port) --- CHANGELOG.md | 1 + README.md | 2 +- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9af5f248..09e31e3c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * fix error when using help in node REPL and there are no doc string * fix escaping regex operators when using string with `apropos` * fix typechecking of number operators [#128](https://github.com/jcubic/lips/issues/128) +* fix indent of call-with- (input-file output-file and port) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 4a190939..27a6d6c0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&2d66b4e25c0341987fe722465b5ff7eb1745d4ef)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&9cf9597022fddbf33247f3fc6133c5869ed66a8a)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 434caedf..bcdfcddb 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 11:31:03 +0000 + * build: Tue, 16 Feb 2021 14:50:19 +0000 */ (function () { 'use strict'; @@ -3708,7 +3708,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { @@ -13100,10 +13100,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 16 Feb 2021 11:31:03 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Feb 2021 14:50:19 +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 Feb 2021 11:31:03 +0000').valueOf(); + var date = LString('Tue, 16 Feb 2021 14:50:19 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13143,7 +13143,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 16 Feb 2021 11:31:03 +0000', + date: 'Tue, 16 Feb 2021 14:50:19 +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 34d6f3df..a4624bdc 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 11:31:03 +0000 + * build: Tue, 16 Feb 2021 14:50:19 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 11:31:03 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 11:31:03 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 14:50:19 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 14:50:19 +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,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/src/lips.js b/src/lips.js index 5d819df4..ef4082f0 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1749,7 +1749,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ /* eslint-enable */ ], shift: { From 91a352c0f6c90de4d75bf6a042c5cba4db43476b Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 18:18:46 +0100 Subject: [PATCH 022/109] improve usage of fs * hide `fs` in internal env * add name to internal env * add automatic bootstrapping of `fs` with BrowserFS if exists --- CHANGELOG.md | 4 ++- README.md | 2 +- dist/lips.js | 15 ++++++---- dist/lips.min.js | 4 +-- dist/std.min.scm | 12 ++++---- dist/std.scm | 74 +++++++++++++++++++++++++++-------------------- lib/R5RS.scm | 61 +++++++++++++++++++------------------- lib/bootstrap.scm | 13 ++++++++- src/lips.js | 6 +++- 9 files changed, 111 insertions(+), 80 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e31e3c..fa6d117c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,14 @@ * add doc strings for `**interaction-environment**` and `**internal-env**` * add `letrec*` that in LIPS is exactly the same as `letrec` * add `pragma->sxml` macro that define `sxml` macro (default is `h`) +* hide `fs` in internal env +* automatic bootstrapping of `fs` with BrowserFS if exists ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string * fix escaping regex operators when using string with `apropos` * fix typechecking of number operators [#128](https://github.com/jcubic/lips/issues/128) -* fix indent of call-with- (input-file output-file and port) +* fix indent of call-with- (input-file, output-file and port) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 27a6d6c0..bd5a4117 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&9cf9597022fddbf33247f3fc6133c5869ed66a8a)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&b6dbf797a464e9dec097e32de14ce345e4d79aab)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index bcdfcddb..25af4fc0 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 14:50:19 +0000 + * build: Tue, 16 Feb 2021 15:59:40 +0000 */ (function () { 'use strict'; @@ -8910,6 +8910,11 @@ }; // ------------------------------------------------------------------------- + Environment.prototype.fs = function () { + return this.get('**fs**'); + }; // ------------------------------------------------------------------------- + + Environment.prototype.unset = function (name) { if (name instanceof LSymbol) { name = name.valueOf(); @@ -9343,7 +9348,7 @@ 'letter-unicode-regex': /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/, 'numeral-unicode-regex': /(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/, 'space-unicode-regex': /[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/ - }); // ------------------------------------------------------------------------- + }, undefined$1, 'internal'); // ------------------------------------------------------------------------- var global_env = new Environment({ nil: nil, @@ -13100,10 +13105,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 16 Feb 2021 14:50:19 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Feb 2021 15:59:40 +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 Feb 2021 14:50:19 +0000').valueOf(); + var date = LString('Tue, 16 Feb 2021 15:59:40 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13143,7 +13148,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 16 Feb 2021 14:50:19 +0000', + date: 'Tue, 16 Feb 2021 15:59:40 +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 a4624bdc..bb0d6872 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 14:50:19 +0000 + * build: Tue, 16 Feb 2021 15:59:40 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"anonymous"}Environment.prototype.list=function(){return get_props(this.__env__)};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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 14:50:19 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 14:50:19 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 15:59:40 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 15:59:40 +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,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/dist/std.min.scm b/dist/std.min.scm index ef5d9427..363f60ab 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -270,7 +270,7 @@ throw exception that function is not yet implemented." (quasiquote (new lips.Env | | | | / \\ | | __| | | | | | __| | | | | | | | / /\\ \\ | | | | | | | | | | | | + |_| + /_/ \\_\\ + |_| + + |_| |_| + + + - \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) Macro that creates special symbol macro for evaluator similar to build in , or `. It's like alias for real macro. Similar to CL reader macros but it receive already @@ -518,13 +518,13 @@ Function return true if argument is input port." (instanceof lips.InputPort obj) Function check it characters is ready in input port. This is usefull mostly for interactive ports that return false if it would wait for user input. -It return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready)))(if (eq? global self) (set! self.fs (require "fs")))(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename) +It return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready)))(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename) Function return new Input Port with given filename. In Browser user need to -provide global fs variable that is instance of FS interface." (if (null? self.fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) "(readFile filename) +provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) "(readFile filename) Helper function that return Promise. NodeJS function sometimes give warnings -when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename))))))(define (close-input-port port) "(close-input-port port) +when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename)))))))(define (close-input-port port) "(close-input-port port) Procedure close port that was opened with open-input-file. After that it no longer accept reading from that port." (typecheck "close-input-port" port "input-port") (port.close))(define (close-output-port port) "(close-output-port port) @@ -542,10 +542,10 @@ even if user proc throw exception." (let ((p (open-output-file filename))) (try Procedure open file and make it current-input-port then thunk is executed. After thunk is executed current-input-port is restored and file port -is closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port)))))(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port)))))(define (file-exists? filename) (new Promise (lambda (resolve) (if (null? self.fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename) +is closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port)))))(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port)))))(define (file-exists? filename) (new Promise (lambda (resolve) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f)))))))))(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename) Function open file and return port that can be used for writing. If file -exists it will throw an Error." (typecheck "open-output-file" filename "string") (if (null? self.fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))(define (scheme-report-environment version) "(scheme-report-environment version) +exists it will throw an Error." (typecheck "open-output-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w")))))))))(define (scheme-report-environment version) "(scheme-report-environment version) Function return new Environment object for given Scheme Spec version. Only argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported"))))))(define-macro (%make-vector prefix type help) "(%make-vector prefix type help) diff --git a/dist/std.scm b/dist/std.scm index d375c6bb..989cea17 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -485,7 +485,7 @@ Helper macro used by cond.") - +;; ----------------------------------------------------------------------------- (define-macro (cond . list) "(cond (predicate? . body) (predicate? . body)) @@ -1212,6 +1212,17 @@ (h (lambda args (apply (g g) args))))))) ;; --------------------------------------------------------------------------------------- +(let ((fs (cond ((eq? self global) (require "fs")) + ((not (null? self.BrowserFS)) + (new Promise (lambda (resolve reject) + (BrowserFS.configure &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) + (if (not (null? fs)) + (--> lips.env (get '**internal-env**) (set "fs" fs)))) ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ ;; | | \ \ | | | || . \/ __> | | @@ -2409,12 +2420,6 @@ (typecheck "char-ready?" port "input-port") (port.char_ready))) -;; ----------------------------------------------------------------------------- -;; NodeJS filesystem functions -;; ----------------------------------------------------------------------------- -(if (eq? global self) - (set! self.fs (require "fs"))) - ;; ----------------------------------------------------------------------------- (define open-input-file (let ((readFile #f)) @@ -2423,18 +2428,19 @@ Function return new Input Port with given filename. In Browser user need to provide global fs variable that is instance of FS interface." - (if (null? self.fs) - (throw (new Error "open-input-file: fs not defined")) - (begin - (if (not (procedure? readFile)) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (filename) - "(readFile filename) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-input-file: fs not defined")) + (begin + (if (not (procedure? readFile)) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (filename) + "(readFile filename) - Helper function that return Promise. NodeJS function sometimes give warnings - when using fs.promises on Windows." - (--> (_readFile filename) (toString)))))) - (new lips.InputFilePort (readFile filename) filename)))))) + Helper function that return Promise. NodeJS function sometimes give warnings + when using fs.promises on Windows." + (--> (_readFile filename) (toString)))))) + (new lips.InputFilePort (readFile filename) filename))))))) ;; ----------------------------------------------------------------------------- (define (close-input-port port) @@ -2512,12 +2518,15 @@ ;; ----------------------------------------------------------------------------- (define (file-exists? filename) (new Promise (lambda (resolve) - (if (null? self.fs) - (throw (new Error "file-exists?: fs not defined")) - (fs.stat filename (lambda (err stat) - (if (null? err) - (resolve (stat.isFile)) - (resolve #f)))))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "file-exists?: fs not defined")) + (fs.stat filename (lambda (err stat) + (if (null? err) + (resolve (stat.isFile)) + (resolve #f))))))))) + + ;; ----------------------------------------------------------------------------- (define open-output-file @@ -2528,14 +2537,15 @@ Function open file and return port that can be used for writing. If file exists it will throw an Error." (typecheck "open-output-file" filename "string") - (if (null? self.fs) - (throw (new Error "open-output-file: fs not defined")) - (begin - (if (not (procedure? open)) - (set! open (promisify fs.open))) - (if (file-exists? filename) - (throw (new Error "open-output-file: file exists")) - (lips.OutputFilePort filename (open filename "w")))))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-output-file: fs not defined")) + (begin + (if (not (procedure? open)) + (set! open (promisify fs.open))) + (if (file-exists? filename) + (throw (new Error "open-output-file: file exists")) + (lips.OutputFilePort filename (open filename "w"))))))))) ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index c4b2ccb1..95f2a5fa 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -1195,12 +1195,6 @@ (typecheck "char-ready?" port "input-port") (port.char_ready))) -;; ----------------------------------------------------------------------------- -;; NodeJS filesystem functions -;; ----------------------------------------------------------------------------- -(if (eq? global self) - (set! self.fs (require "fs"))) - ;; ----------------------------------------------------------------------------- (define open-input-file (let ((readFile #f)) @@ -1209,18 +1203,19 @@ Function return new Input Port with given filename. In Browser user need to provide global fs variable that is instance of FS interface." - (if (null? self.fs) - (throw (new Error "open-input-file: fs not defined")) - (begin - (if (not (procedure? readFile)) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (filename) - "(readFile filename) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-input-file: fs not defined")) + (begin + (if (not (procedure? readFile)) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (filename) + "(readFile filename) - Helper function that return Promise. NodeJS function sometimes give warnings - when using fs.promises on Windows." - (--> (_readFile filename) (toString)))))) - (new lips.InputFilePort (readFile filename) filename)))))) + Helper function that return Promise. NodeJS function sometimes give warnings + when using fs.promises on Windows." + (--> (_readFile filename) (toString)))))) + (new lips.InputFilePort (readFile filename) filename))))))) ;; ----------------------------------------------------------------------------- (define (close-input-port port) @@ -1298,12 +1293,15 @@ ;; ----------------------------------------------------------------------------- (define (file-exists? filename) (new Promise (lambda (resolve) - (if (null? self.fs) - (throw (new Error "file-exists?: fs not defined")) - (fs.stat filename (lambda (err stat) - (if (null? err) - (resolve (stat.isFile)) - (resolve #f)))))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "file-exists?: fs not defined")) + (fs.stat filename (lambda (err stat) + (if (null? err) + (resolve (stat.isFile)) + (resolve #f))))))))) + + ;; ----------------------------------------------------------------------------- (define open-output-file @@ -1314,14 +1312,15 @@ Function open file and return port that can be used for writing. If file exists it will throw an Error." (typecheck "open-output-file" filename "string") - (if (null? self.fs) - (throw (new Error "open-output-file: fs not defined")) - (begin - (if (not (procedure? open)) - (set! open (promisify fs.open))) - (if (file-exists? filename) - (throw (new Error "open-output-file: file exists")) - (lips.OutputFilePort filename (open filename "w")))))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-output-file: fs not defined")) + (begin + (if (not (procedure? open)) + (set! open (promisify fs.open))) + (if (file-exists? filename) + (throw (new Error "open-output-file: file exists")) + (lips.OutputFilePort filename (open filename "w"))))))))) ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 6d09756c..a7d0c1d9 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -485,7 +485,7 @@ Helper macro used by cond.") - +;; ----------------------------------------------------------------------------- (define-macro (cond . list) "(cond (predicate? . body) (predicate? . body)) @@ -1212,3 +1212,14 @@ (h (lambda args (apply (g g) args))))))) ;; --------------------------------------------------------------------------------------- +(let ((fs (cond ((eq? self global) (require "fs")) + ((not (null? self.BrowserFS)) + (new Promise (lambda (resolve reject) + (BrowserFS.configure &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) + (if (not (null? fs)) + (--> lips.env (get '**internal-env**) (set "fs" fs)))) diff --git a/src/lips.js b/src/lips.js index ef4082f0..7bbd553f 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5641,6 +5641,10 @@ return get_props(this.__env__); }; // ------------------------------------------------------------------------- + Environment.prototype.fs = function() { + return this.get('**fs**'); + }; + // ------------------------------------------------------------------------- Environment.prototype.unset = function(name) { if (name instanceof LSymbol) { name = name.valueOf(); @@ -5996,7 +6000,7 @@ 'letter-unicode-regex': /\p{L}/u, 'numeral-unicode-regex': /\p{N}/u, 'space-unicode-regex': /\s/u - }); + }, undefined, 'internal'); // ------------------------------------------------------------------------- var global_env = new Environment({ nil, From 1cd33667360e9f0c896076fc351a73d8088c283d Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 18:51:08 +0100 Subject: [PATCH 023/109] update delete-file to use internal env and add doc string --- dist/std.scm | 2 ++ lib/R7RS.scm | 16 ++++++++++------ lib/bootstrap.scm | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dist/std.scm b/dist/std.scm index 989cea17..de2d9166 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1223,6 +1223,8 @@ (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) + +;; --------------------------------------------------------------------------------------- ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ ;; | | \ \ | | | || . \/ __> | | diff --git a/lib/R7RS.scm b/lib/R7RS.scm index ab473a78..d01afcb7 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -594,13 +594,17 @@ (define delete-file (let ((unlink #f)) (lambda (filename) + "(delete-file filename) + + Function delete the file of given name." (typecheck "delete-file" filename "string") - (if (null? self.fs) - (throw (new Error "delete-file: fs not defined")) - (begin - (if (not (procedure? unlink)) - (set! unlink (promisify fs.unlink))) - (unlink filename)))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "delete-file: fs not defined")) + (begin + (if (not (procedure? unlink)) + (set! unlink (promisify fs.unlink))) + (unlink filename))))))) ;; ----------------------------------------------------------------------------- (define (call-with-port port proc) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index a7d0c1d9..a0631c02 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1223,3 +1223,5 @@ (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) + +;; --------------------------------------------------------------------------------------- From 9edd1fe18331ee340949c7d53ae1e7a682c4a71a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 19:08:06 +0100 Subject: [PATCH 024/109] fix fs in browser (remove all refs to self.fs) --- README.md | 2 +- dist/lips.js | 22 ++++++++++++++++------ dist/lips.min.js | 4 ++-- dist/std.min.scm | 6 ++++-- dist/std.scm | 35 +++++++++++++++++++---------------- lib/bootstrap.scm | 19 +++++++++---------- src/lips.js | 11 +++++++++-- 7 files changed, 60 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index bd5a4117..c7835cc0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&b6dbf797a464e9dec097e32de14ce345e4d79aab)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&1cd33667360e9f0c896076fc351a73d8088c283d)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 25af4fc0..c5f207e0 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 15:59:40 +0000 + * build: Tue, 16 Feb 2021 18:06:58 +0000 */ (function () { 'use strict'; @@ -8714,18 +8714,28 @@ x = x.valueOf(); } - root.fs.write(_this8._fd, x, function () {}); + _this8.fs('write')(_this8._fd, x, function () {}); }; } OutputFilePort.prototype = Object.create(OutputPort.prototype); OutputFilePort.prototype.constructor = OutputFilePort; + OutputFilePort.prototype.fs = function (name) { + var fs = user_env.get('**internal-env**').get('fs'); + + if (!fs) { + throw new Error("".concat(name, ": fs is not defined")); + } + + return fs[name]; + }; + OutputFilePort.prototype.close = function () { var _this9 = this; return new Promise(function (resolve, reject) { - root.fs.close(_this9._fd, function (err) { + _this9.fs('close')(_this9._fd, function (err) { if (err) { reject(err); } else { @@ -13105,10 +13115,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 16 Feb 2021 15:59:40 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Feb 2021 18:06:58 +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 Feb 2021 15:59:40 +0000').valueOf(); + var date = LString('Tue, 16 Feb 2021 18:06:58 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13148,7 +13158,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 16 Feb 2021 15:59:40 +0000', + date: 'Tue, 16 Feb 2021 18:06:58 +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 bb0d6872..0aedcbc6 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 15:59:40 +0000 + * build: Tue, 16 Feb 2021 18:06:58 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}root.fs.write(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){root.fs.close(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 15:59:40 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 15:59:40 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 18:06:58 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 18:06:58 +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,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/dist/std.min.scm b/dist/std.min.scm index 363f60ab..a190c428 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -270,7 +270,7 @@ throw exception that function is not yet implemented." (quasiquote (new lips.Env | | | | / \\ | | __| | | | | | __| | | | | | | | / /\\ \\ | | | | | | | | | | | | + |_| + /_/ \\_\\ + |_| + + |_| |_| + + + - \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) Macro that creates special symbol macro for evaluator similar to build in , or `. It's like alias for real macro. Similar to CL reader macros but it receive already @@ -655,7 +655,9 @@ Function create new output port that can used to write string into and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr))(define (get-output-string port) "(get-output-string port) Function get full string from string port. If nothing was wrote -to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define delete-file (let ((unlink #f)) (lambda (filename) (typecheck "delete-file" filename "string") (if (null? self.fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename))))))(define (call-with-port port proc) "(call-with-port port proc) +to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) + +Function delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename)))))))(define (call-with-port port proc) "(call-with-port port proc) Proc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close)))))(define (close-port port) "(close-port port) diff --git a/dist/std.scm b/dist/std.scm index de2d9166..371f754f 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1212,18 +1212,17 @@ (h (lambda args (apply (g g) args))))))) ;; --------------------------------------------------------------------------------------- -(let ((fs (cond ((eq? self global) (require "fs")) - ((not (null? self.BrowserFS)) - (new Promise (lambda (resolve reject) - (BrowserFS.configure &(:fs "IndexedDB" - :options &()) - (lambda (e) - (if (null? e) - (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) +(let* ((fs (cond ((eq? self global) (require "fs")) + ((not (null? self.BrowserFS)) + (new Promise (lambda (resolve reject) + (BrowserFS.configure &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) - ;; --------------------------------------------------------------------------------------- ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ @@ -3320,13 +3319,17 @@ (define delete-file (let ((unlink #f)) (lambda (filename) + "(delete-file filename) + + Function delete the file of given name." (typecheck "delete-file" filename "string") - (if (null? self.fs) - (throw (new Error "delete-file: fs not defined")) - (begin - (if (not (procedure? unlink)) - (set! unlink (promisify fs.unlink))) - (unlink filename)))))) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "delete-file: fs not defined")) + (begin + (if (not (procedure? unlink)) + (set! unlink (promisify fs.unlink))) + (unlink filename))))))) ;; ----------------------------------------------------------------------------- (define (call-with-port port proc) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index a0631c02..002720cd 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1212,16 +1212,15 @@ (h (lambda args (apply (g g) args))))))) ;; --------------------------------------------------------------------------------------- -(let ((fs (cond ((eq? self global) (require "fs")) - ((not (null? self.BrowserFS)) - (new Promise (lambda (resolve reject) - (BrowserFS.configure &(:fs "IndexedDB" - :options &()) - (lambda (e) - (if (null? e) - (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) +(let* ((fs (cond ((eq? self global) (require "fs")) + ((not (null? self.BrowserFS)) + (new Promise (lambda (resolve reject) + (BrowserFS.configure &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) - ;; --------------------------------------------------------------------------------------- diff --git a/src/lips.js b/src/lips.js index 7bbd553f..64d909a2 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5496,14 +5496,21 @@ } else { x = x.valueOf(); } - root.fs.write(this._fd, x, function() { }); + this.fs('write')(this._fd, x, function() { }); }; } OutputFilePort.prototype = Object.create(OutputPort.prototype); OutputFilePort.prototype.constructor = OutputFilePort; + OutputFilePort.prototype.fs = function(name) { + var fs = user_env.get('**internal-env**').get('fs'); + if (!fs) { + throw new Error(`${name}: fs is not defined`); + } + return fs[name]; + }; OutputFilePort.prototype.close = function() { return new Promise((resolve, reject) => { - root.fs.close(this._fd, (err) => { + this.fs('close')(this._fd, (err) => { if (err) { reject(err); } else { From 5460463c28ae94b94da5a9ed4fae619d49302bc5 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 20:15:00 +0100 Subject: [PATCH 025/109] add I/O example --- examples/io.scm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/io.scm diff --git a/examples/io.scm b/examples/io.scm new file mode 100644 index 00000000..718f5e47 --- /dev/null +++ b/examples/io.scm @@ -0,0 +1,21 @@ +(let ((fname "tmp.txt")) + (if (file-exists? fname) + (raise (string-append "file " fname " exists"))) + (call-with-output-file fname + (lambda (output-port) + (display "hello, world" output-port) + (newline output-port))) + + (call-with-input-file fname + (lambda (input-port) + (let loop ((x (read-char input-port))) + (if (not (eof-object? x)) + (begin + (display x) + (loop (read-char input-port))))))) + + (delete-file fname)) + + + + From 970df2fac045f201576375f397bf3cc276053f04 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 16 Feb 2021 20:36:11 +0100 Subject: [PATCH 026/109] add example with reading data from /dev/zero --- examples/zero.scm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 examples/zero.scm diff --git a/examples/zero.scm b/examples/zero.scm new file mode 100755 index 00000000..cf6a42b3 --- /dev/null +++ b/examples/zero.scm @@ -0,0 +1,17 @@ +#!/usr/bin/env -S lips -t + +(define fs (require "fs")) + +(define (read-zero n) + (new Promise (lambda (resolve reject) + (fs.open "/dev/zero" "r" (lambda (err fd) + (if (null? err) + (let* ((buffer (Buffer.from (new Array n))) + (return (lambda (err num) + (if (null? err) + (resolve buffer) + (reject err))))) + (fs.read fd buffer 0 buffer.length 0 return)) + (reject err))))))) + +(console.log (read-zero 8)) From 6a2419ad6141b94f96bcdf310b826bc2a205f267 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 17 Feb 2021 10:33:05 +0100 Subject: [PATCH 027/109] make `dir` return list of symbols --- CHANGELOG.md | 4 ++-- README.md | 4 ++-- dist/std.min.scm | 2 +- dist/std.scm | 3 ++- lib/bootstrap.scm | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6d117c..e5feedfd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## 1.0.0-beta.12 ### Breaking -* `env` now return symbols instead of strings -* repr and type of quoted promises that show `#` and `promise` +* `env` and `dir` now returns symbols instead of strings +* `repr` and `type` of quoted promises now return `#` and `promise` ### Features * create minfied std scheme file for faster bootstrap * add `list-copy` diff --git a/README.md b/README.md index c7835cc0..9c14ef3b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&1cd33667360e9f0c896076fc351a73d8088c283d)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&970df2fac045f201576375f397bf3cc276053f04)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ef48bcf267790da8598dfe6d127818eb)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/std.min.scm b/dist/std.min.scm index a190c428..a22f376c 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -86,7 +86,7 @@ Function return hidden names of an object, for ES6 class prototype it return all methods since they are indistinguishable from hidden property created using defineProperty." (let* ((descriptors (Object.getOwnPropertyDescriptors obj)) (names (Object.keys descriptors))) (--> names (filter (lambda (name) (let ((descriptor (. descriptors name))) (eq? descriptor.enumerable #f)))))))(define (dir obj . rest) "(dir obj) -Function return all props on the object including those in prototype chain." (if (or (null? obj) (eq? obj Object.prototype)) () (let ((proto (if (null? rest) #f (car rest))) (names (Object.getOwnPropertyNames obj))) (if (not proto) (let ((hidden (%hidden-props obj))) (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) (append (array->list names) (dir (Object.getPrototypeOf obj) #t)))))(define (tree-map f tree) "(tree-map fn tree) +Function return all props on the object including those in prototype chain." (if (or (null? obj) (eq? obj Object.prototype)) () (let ((proto (if (null? rest) #f (car rest))) (names (Object.getOwnPropertyNames obj))) (if (not proto) (let ((hidden (%hidden-props obj))) (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) (append (array->list (--> names (map (unary string->symbol)))) (dir (Object.getPrototypeOf obj) #t)))))(define (tree-map f tree) "(tree-map fn tree) Tree version of map. Function is invoked on every leaf." (if (pair? tree) (cons (tree-map f (car tree)) (tree-map f (cdr tree))) (f tree)))(define (native.number x) "(native.number obj) diff --git a/dist/std.scm b/dist/std.scm index 371f754f..bc5bdc2d 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -375,7 +375,8 @@ (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) - (append (array->list names) (dir (Object.getPrototypeOf obj) true))))) + (append (array->list (--> names (map (unary string->symbol)))) + (dir (Object.getPrototypeOf obj) true))))) ;; --------------------------------------------------------------------------------------- (define (tree-map f tree) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 002720cd..25b3f468 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -375,7 +375,8 @@ (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) - (append (array->list names) (dir (Object.getPrototypeOf obj) true))))) + (append (array->list (--> names (map (unary string->symbol)))) + (dir (Object.getPrototypeOf obj) true))))) ;; --------------------------------------------------------------------------------------- (define (tree-map f tree) From ae17c1a6c06138f2f917567524ddfa639eef4ffa Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 17 Feb 2021 11:00:24 +0100 Subject: [PATCH 028/109] fix prism of names for REPL help tooltips --- lib/js/prism.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/js/prism.js b/lib/js/prism.js index ad6409ea..1e32cafe 100755 --- a/lib/js/prism.js +++ b/lib/js/prism.js @@ -39,6 +39,6 @@ var keyword = Prism.languages.scheme.keyword.pattern; Prism.languages.scheme.keyword.pattern = new RegExp(keyword.source.replace(/\|when/, '|when|set-obj!|let-env|try|catch|throw|raise')); // names should be marked so we can show help message on higher order function that have function as argument Prism.languages.scheme.name = { - pattern: /(^|[()[\]\s][^#])[^()\s]*/g, + pattern: /(^|[()[\]\s])[^#()[\]\s][^()\s]+/g, lookbehind: true }; From 9cefd8c9456b8c969cf47383dc74e80e8de94310 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 17 Feb 2021 11:30:37 +0100 Subject: [PATCH 029/109] remove whitespaces + add message when rejection is null --- benchmarks/regex.scm | 8 -------- bin/lips.js | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/benchmarks/regex.scm b/benchmarks/regex.scm index a8945ff2..9957f62f 100755 --- a/benchmarks/regex.scm +++ b/benchmarks/regex.scm @@ -23,7 +23,6 @@ (on "cycle" (lambda (e) (print (string-append ">>> " (String e.target))))) - (on "complete" (lambda (e) (try @@ -34,11 +33,4 @@ (catch (e) (print e))))) - - - (run &(:async true))) - - - - diff --git a/bin/lips.js b/bin/lips.js index 079bd89b..8c58662c 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -54,6 +54,10 @@ function run(code, interpreter, dynamic = false, env = null, stack = false) { code = code.toString(); } return interpreter.exec(code, dynamic, env).catch(function(e) { + if (!e) { + console.log('Error is null'); + return; + } if (!stack) { console.error(e.message); } From 0e10fa2404058aad8e0d0fb30e8d67d054943c1f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 17 Feb 2021 12:22:00 +0100 Subject: [PATCH 030/109] fix `repr` of bound anonymous functions Fix whitespace after name of bound function when calling `repr` --- README.md | 2 +- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9c14ef3b..58b91a29 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&970df2fac045f201576375f397bf3cc276053f04)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&ae17c1a6c06138f2f917567524ddfa639eef4ffa)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ef48bcf267790da8598dfe6d127818eb)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index c5f207e0..170e7182 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 18:06:58 +0000 + * build: Wed, 17 Feb 2021 11:21:03 +0000 */ (function () { 'use strict'; @@ -4600,7 +4600,7 @@ if (has_own_function(fn, 'toString')) { return fn.toString(); } else if (fn.name && !fn[__lambda__]) { - return "#"); + return "#"); } else { return '#'; } @@ -13115,10 +13115,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 16 Feb 2021 18:06:58 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 17 Feb 2021 11:21:03 +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 Feb 2021 18:06:58 +0000').valueOf(); + var date = LString('Wed, 17 Feb 2021 11:21:03 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13158,7 +13158,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 16 Feb 2021 18:06:58 +0000', + date: 'Wed, 17 Feb 2021 11:21:03 +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 0aedcbc6..2b3666a9 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 16 Feb 2021 18:06:58 +0000 + * build: Wed, 17 Feb 2021 11:21:03 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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 Feb 2021 18:06:58 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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 Feb 2021 18:06:58 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 17 Feb 2021 11:21:03 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 17 Feb 2021 11:21:03 +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,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/src/lips.js b/src/lips.js index 64d909a2..bf836f53 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2476,7 +2476,7 @@ if (has_own_function(fn, 'toString')) { return fn.toString(); } else if (fn.name && !fn[__lambda__]) { - return `#`; + return `#`; } else { return '#'; } From fc1929a1760131ed557a87cbebca9311d2b4d997 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 18 Feb 2021 12:03:46 +0100 Subject: [PATCH 031/109] add syntax highlighting to pprint in web REPL #33 --- lib/js/terminal.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/js/terminal.js b/lib/js/terminal.js index 8287c883..4bffcf84 100644 --- a/lib/js/terminal.js +++ b/lib/js/terminal.js @@ -8,7 +8,7 @@ * Copyright (C) Jakub T. Jankiewicz * Released under MIT license */ -/* global jQuery, clearTimeout, setTimeout */ +/* global jQuery, $, clearTimeout, setTimeout */ function terminal({selector, lips, dynamic = false, name = 'terminal'}, undefined) { var position; @@ -57,7 +57,20 @@ function terminal({selector, lips, dynamic = false, name = 'terminal'}, undefine if (doc !== undefined) { term.echo(doc, { formatters: false }); } - }), lips.env.get('help').__doc__), + }), help.__doc__), + // --------------------------------------------------------------------- + pprint: doc(function(arg) { + if (arg instanceof lips.Pair) { + arg = new lips.Formatter(arg.toString(true)).break().format(); + if ($.terminal.prism) { + arg = $.terminal.prism('scheme', arg, {echo: true}); + } + this.get('display').call(this, arg); + } else { + this.get('write').call(this, arg); + } + this.get('newline').call(this); + }, lips.env.get('pprint').__doc__), // --------------------------------------------------------------------- 'stack-trace': doc(function() { if (strace) { From 03efe94c6ee85f8baef29cd9891a43a5e65cd24f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 18 Feb 2021 12:07:57 +0100 Subject: [PATCH 032/109] add syntax highlighting to pprint in Node REPL #33 --- bin/lips.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bin/lips.js b/bin/lips.js index 8c58662c..be989740 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -169,8 +169,7 @@ var interp = Interpreter('repl', { }); }); }), - __dirname: __dirname, - __filename: __filename, + // ------------------------------------------------------------------------- stdout: OutputPort(function(x) { if (typeof x !== 'string') { x = this.get('repr')(x); @@ -178,6 +177,10 @@ var interp = Interpreter('repl', { newline = !x.match(/\n$/); process.stdout.write(x); }), + // ------------------------------------------------------------------------- + __dirname: __dirname, + __filename: __filename, + // ------------------------------------------------------------------------- 'stack-trace': doc(function() { if (strace) { console.log(strace); @@ -185,12 +188,24 @@ var interp = Interpreter('repl', { }, `(stack-trace) Function display stack trace of last error`), + // ------------------------------------------------------------------------- exit: doc(function(code) { process.exit(code); }, `(exit) (exit error-code) Function exits LIPS script or the REPL.`), + // ------------------------------------------------------------------------- + pprint: doc(function(arg) { + if (arg instanceof Pair) { + arg = new Formatter(arg.toString(true)).break().format(); + this.get('display').call(this, scheme(arg)); + } else { + this.get('write').call(this, scheme(arg)); + } + this.get('newline').call(this); + }, env.get('pprint').__doc__), + // ------------------------------------------------------------------------- help: doc(new Macro('help', function(code, { error }) { var new_code = new Pair(new LSymbol('__help'), code); var doc = evaluate(new_code, { env: this, error }); @@ -198,6 +213,7 @@ var interp = Interpreter('repl', { console.log(doc.toString()); } }), env.get('help').__doc__), + // ------------------------------------------------------------------------- '__help': env.get('help') }); From 3f8df77010b41900b666b3dc877ab1e3976f747f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 18 Feb 2021 12:09:57 +0100 Subject: [PATCH 033/109] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5feedfd..b259bf3a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * add `pragma->sxml` macro that define `sxml` macro (default is `h`) * hide `fs` in internal env * automatic bootstrapping of `fs` with BrowserFS if exists +* `pprint` in both REPLs now print in color [#33](https://github.com/jcubic/lips/issues/33) ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string From e136b0a38212188e9ba3eccbb904ec45c185e6af Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 23 Feb 2021 16:50:53 +0100 Subject: [PATCH 034/109] include BrowserFS in bookmark --- lib/js/bookmark.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/js/bookmark.js b/lib/js/bookmark.js index ef665575..eb95c035 100755 --- a/lib/js/bookmark.js +++ b/lib/js/bookmark.js @@ -140,6 +140,7 @@ javascript:(function(next) { `gh/jcubic/lips@${REF}/lib/js/prism.js`, 'npm/js-polyfills/keyboard.js' ].join(','), + 'https://cdn.jsdelivr.net/npm/browserfs@1.x.x/dist/browserfs.min.js' ]; (function recur() { var script = scripts.shift(); From 07c5ed3261cf8484ee1b5fdf0170d9b30470ebfe Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Tue, 23 Feb 2021 17:02:52 +0100 Subject: [PATCH 035/109] typecheck port in display and write-char --- README.md | 4 ++-- dist/lips.js | 10 ++++++---- dist/lips.min.js | 4 ++-- dist/std.min.scm | 2 +- dist/std.scm | 2 ++ lib/R5RS.scm | 2 ++ src/lips.js | 2 ++ 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 58b91a29..cb2ea44b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&ae17c1a6c06138f2f917567524ddfa639eef4ffa)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ef48bcf267790da8598dfe6d127818eb)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&e136b0a38212188e9ba3eccbb904ec45c185e6af)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 170e7182..062fab4a 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 17 Feb 2021 11:21:03 +0000 + * build: Tue, 23 Feb 2021 16:02:35 +0000 */ (function () { 'use strict'; @@ -9575,6 +9575,8 @@ if (port === null) { port = internal(this, 'stdout'); + } else { + typecheck('display', port, 'output-port'); } var value = global_env.get('repr')(arg); @@ -13115,10 +13117,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 17 Feb 2021 11:21:03 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 23 Feb 2021 16:02:35 +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('Wed, 17 Feb 2021 11:21:03 +0000').valueOf(); + var date = LString('Tue, 23 Feb 2021 16:02:35 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13158,7 +13160,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 17 Feb 2021 11:21:03 +0000', + date: 'Tue, 23 Feb 2021 16:02:35 +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 2b3666a9..34727b55 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 17 Feb 2021 11:21:03 +0000 + * build: Tue, 23 Feb 2021 16:02:35 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 17 Feb 2021 11:21:03 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 17 Feb 2021 11:21:03 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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, 23 Feb 2021 16:02:35 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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, 23 Feb 2021 16:02:35 +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,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/dist/std.min.scm b/dist/std.min.scm index a22f376c..700c5117 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -469,7 +469,7 @@ Write newline character to standard output or given port" (let ((port (if (null? Write object to standard output or give port. For strings it will include wrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (display (repr obj #t) port)))(define (write-char char . rest) "(write-char char [port]) -Write single character to given port using write function." (typecheck "write-char" char "character") (apply display (cons (char.valueOf) rest)))(define fold-right reduce)(define fold-left fold)(define (make-vector n . rest) "(make-vector n [fill]) +Write single character to given port using write function." (typecheck "write-char" char "character") (if (not (null? rest)) (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest)))(define fold-right reduce)(define fold-left fold)(define (make-vector n . rest) "(make-vector n [fill]) Create new vector with n empty elements. If fill is specified it will set all elements of the vector to that value." (let ((result (new Array n))) (if (not (null? rest)) (--> result (fill (car rest))) result)))(define (vector? n) "(vector? n) diff --git a/dist/std.scm b/dist/std.scm index bc5bdc2d..8aca9ba1 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2193,6 +2193,8 @@ Write single character to given port using write function." (typecheck "write-char" char "character") + (if (not (null? rest)) + (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest))) ;; ----------------------------------------------------------------------------- diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 95f2a5fa..a223a024 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -966,6 +966,8 @@ Write single character to given port using write function." (typecheck "write-char" char "character") + (if (not (null? rest)) + (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest))) ;; ----------------------------------------------------------------------------- diff --git a/src/lips.js b/src/lips.js index bf836f53..90846243 100644 --- a/src/lips.js +++ b/src/lips.js @@ -6143,6 +6143,8 @@ display: doc(function display(arg, port = null) { if (port === null) { port = internal(this, 'stdout'); + } else { + typecheck('display', port, 'output-port'); } const value = global_env.get('repr')(arg); port.write.call(global_env, value); From 123a6479bfdb150dfeed5fb32005e88020fc6e3e Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Feb 2021 11:08:46 +0100 Subject: [PATCH 036/109] fix eq? and type of NaN #130 --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 14 +++++++++----- dist/lips.min.js | 4 ++-- src/lips.js | 5 ++++- tests/numbers.scm | 6 ++++++ 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b259bf3a..a2d30456 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * fix escaping regex operators when using string with `apropos` * fix typechecking of number operators [#128](https://github.com/jcubic/lips/issues/128) * fix indent of call-with- (input-file, output-file and port) +* fix eq? and type of NaN [#130](https://github.com/jcubic/lips/issues/130) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index cb2ea44b..a8328f72 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&e136b0a38212188e9ba3eccbb904ec45c185e6af)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&95dc4fe97d85500128aeed83b52d68dd)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&07c5ed3261cf8484ee1b5fdf0170d9b30470ebfe)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0708d984ff6eebf7ebdde192d2fcbba0)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 062fab4a..0a59f386 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 23 Feb 2021 16:02:35 +0000 + * build: Wed, 24 Feb 2021 10:08:00 +0000 */ (function () { 'use strict'; @@ -5095,6 +5095,10 @@ return false; } + if (Number.isNaN(x)) { + return Number.isNaN(y); + } + x = LNumber(x); y = LNumber(y); return x.__type__ === y.__type__ && x.cmp(y) === 0; @@ -12200,7 +12204,7 @@ }; if (Number.isNaN(obj)) { - return 'NaN '; + return 'NaN'; } if (obj === nil) { @@ -13117,10 +13121,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 23 Feb 2021 16:02:35 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Feb 2021 10:08:00 +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, 23 Feb 2021 16:02:35 +0000').valueOf(); + var date = LString('Wed, 24 Feb 2021 10:08:00 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13160,7 +13164,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 23 Feb 2021 16:02:35 +0000', + date: 'Wed, 24 Feb 2021 10:08:00 +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 34727b55..a3784ee9 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 23 Feb 2021 16:02:35 +0000 + * build: Wed, 24 Feb 2021 10:08:00 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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, 23 Feb 2021 16:02:35 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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, 23 Feb 2021 16:02:35 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(r)}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 10:08:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 10:08:00 +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,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/src/lips.js b/src/lips.js index 90846243..7c29522c 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2862,6 +2862,9 @@ if (typeof y !== 'number') { return false; } + if (Number.isNaN(x)) { + return Number.isNaN(y); + } x = LNumber(x); y = LNumber(y); return x.__type__ === y.__type__ && x.cmp(y) === 0; @@ -8646,7 +8649,7 @@ 'native-symbol': Symbol }; if (Number.isNaN(obj)) { - return 'NaN '; + return 'NaN'; } if (obj === nil) { return 'nil'; diff --git a/tests/numbers.scm b/tests/numbers.scm index 4a8b171b..c4d9a8a1 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -454,3 +454,9 @@ (t.is (negative? -10) #t) (t.is (negative? -1/2) #t) (t.is (negative? -0.5) #t))) + +(test "numbers: NaN" + (lambda (t) + (t.is (eq? NaN NaN) true) + (t.is (eq? 10 NaN) false) + (t.is (eq? NaN 10) false))) From 52ff387952789067b796ba1ab5998fa239d4d50a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Feb 2021 13:39:35 +0100 Subject: [PATCH 037/109] fixes and improvements to numerical tower #34 * add `nan?`, `infinite?` and `finite?` functions * fix `real-part` function * fix number predicates `number?`, `complex?`, `real?`, `rational?` and `integer?` --- CHANGELOG.md | 3 ++ README.md | 4 +- dist/lips.js | 20 ++++++--- dist/lips.min.js | 4 +- dist/std.min.scm | 32 ++++++++++---- dist/std.scm | 104 ++++++++++++++++++++++++++++++++++++---------- lib/R5RS.scm | 70 +++++++++++++++++++++---------- lib/R7RS.scm | 34 +++++++++++++++ src/lips.js | 15 ++++--- tests/numbers.scm | 34 +++++++++++++++ 10 files changed, 251 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2d30456..1ea2be02 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * hide `fs` in internal env * automatic bootstrapping of `fs` with BrowserFS if exists * `pprint` in both REPLs now print in color [#33](https://github.com/jcubic/lips/issues/33) +* add `nan?`, `infinite?` and `finite?` functions ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string @@ -21,6 +22,8 @@ * fix typechecking of number operators [#128](https://github.com/jcubic/lips/issues/128) * fix indent of call-with- (input-file, output-file and port) * fix eq? and type of NaN [#130](https://github.com/jcubic/lips/issues/130) +* fix number predicates +* fix `real-part` function ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index a8328f72..d4670359 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&07c5ed3261cf8484ee1b5fdf0170d9b30470ebfe)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0708d984ff6eebf7ebdde192d2fcbba0)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&123a6479bfdb150dfeed5fb32005e88020fc6e3e)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&21f4261fd3cea6dc46e8366fa056c826)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 0a59f386..b485297a 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 10:08:00 +0000 + * build: Wed, 24 Feb 2021 12:17:30 +0000 */ (function () { 'use strict'; @@ -5099,6 +5099,14 @@ return Number.isNaN(y); } + if (x === Number.NEGATIVE_INFINITY) { + return y === Number.NEGATIVE_INFINITY; + } + + if (x === Number.POSITIVE_INFINITY) { + return y === Number.POSITIVE_INFINITY; + } + x = LNumber(x); y = LNumber(y); return x.__type__ === y.__type__ && x.cmp(y) === 0; @@ -11229,7 +11237,9 @@ return LNumber.isFloat(value); }, "(real? number)\n\n Function check if value is real number."), // ------------------------------------------------------------------ - 'number?': doc('number?', LNumber.isNumber, "(number? expression)\n\n Function check if value is a number"), + 'number?': doc('number?', function (x) { + return Number.isNaN(x) || LNumber.isNumber(x); + }, "(number? expression)\n\n Function check if value is a number or NaN value."), // ------------------------------------------------------------------ 'string?': doc('string?', function (obj) { return LString.isString(obj); @@ -13121,10 +13131,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 24 Feb 2021 10:08:00 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Feb 2021 12:17:30 +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('Wed, 24 Feb 2021 10:08:00 +0000').valueOf(); + var date = LString('Wed, 24 Feb 2021 12:17:30 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13164,7 +13174,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 24 Feb 2021 10:08:00 +0000', + date: 'Wed, 24 Feb 2021 12:17:30 +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 a3784ee9..a5e2579f 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 10:08:00 +0000 + * build: Wed, 24 Feb 2021 12:17:30 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}return false}else if(typeof e==="number"){if(typeof r!=="number"){return false}if(Number.isNaN(e)){return Number.isNaN(r)}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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?",LNumber.isNumber,"(number? expression)\n\n Function check if value is a number"),"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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 10:08:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 10:08:00 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 12:17:30 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 12:17:30 +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,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/dist/std.min.scm b/dist/std.min.scm index 700c5117..5856f2ae 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -310,7 +310,15 @@ Function return true if value is boolean." (string=? (type x) "boolean"))(define Return i element from vector." (typecheck "number->string" vector "array" 1) (typecheck "number->string" i "number" 2) (. vector i))(define (vector-set! vector i obj) "(vector-set! vector i obj) -Set obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj))(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type)))))(define integer? (%doc "" (curry %number-type "bigint")))(define complex? (%doc "" (curry %number-type "complex")))(define rational? (%doc "" (curry %number-type (quote ("rational" "bigint")))))(define (typecheck-args _type name _list) "(typecheck-args args type) +Set obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj))(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type)))))(define (real? x) "(real? x) + +Function check if argument x is real." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (%number-type "complex" x) (zero? (imag-part x))) (%number-type (quote ("float" "bigint" "rational")) x))))(define (integer? x) "(integer? x) + +Function check if argument x is integer." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1)))))(define (complex? x) "(complex? x) + +Function check if argument x is complex." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (%number-type (quote ("complex" "float" "bigint" "rational")) x))))(define (rational? x) "(rational? x) + +Function check if value is rational." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "rational" x) (integer? x))))(define (typecheck-args _type name _list) "(typecheck-args args type) Function check if all items in array are of same type." (let iter ((n 1) (_list _list)) (if (pair? _list) (begin (typecheck name (car _list) _type n) (iter (+ n 1) (cdr _list))))))(define numbers? (curry typecheck-args "number"))(define (max . args) "(max n1 n2 ...) @@ -318,11 +326,11 @@ Return maximum of it's arguments." (numbers? "max" args) (apply (.. Math.max) ar Return minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) args))(define (make-rectangular re im) "(make-rectangular im re) -Create complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t)))))(define (real? n) "(real? n)" (and (number? n) (let ((type n.__type__)) (or (string=? type "float") (string=? type "bigint")))))(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__)))))(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n)))(define (exact->inexact n) "(exact->inexact n) +Create complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t)))))(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__)))))(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n)))(define (exact->inexact n) "(exact->inexact n) -Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (complex? n) (lips.LComplex (object :im (. n (quote im)) :re (. n (quote re)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) +Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (. n (quote im)) :re (. n (quote re)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) -Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (complex? n)) (--> n (toRational)) n))(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan"))(define _this_env (current-environment))(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n) +Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n))(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan"))(define _this_env (current-environment))(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n) Function calculate " name " math operation (it call JavaScript Math)." name " function.")) (iter (cdr fns)))))(define (modulo a b) "(modulo a b) @@ -495,15 +503,15 @@ Return numberator of rational or same number if n is not rational." (typecheck " Return denominator of rational or same number if one is not rational." (typecheck "denominator" n "number") (if (and (rational? n) (not (integer? n))) n.denom (if (exact? n) 1 1.0)))(define (imag-part n) "(imag-part n) -Return imaginary part of the complex number n." (typecheck "imag-part" n "number") (if (complex? n) n.__im__ 0))(define (real-part n) "(real-part n) +Return imaginary part of the complex number n." (typecheck "imag-part" n "number") (if (%number-type "complex" n) n.__im__ 0))(define (real-part n) "(real-part n) -Return real part of the complex number n." (typecheck "real-part" n "number") (if (complex? n) n.re n))(define (make-polar r angle) "(make-polar magnitude angle) +Return real part of the complex number n." (typecheck "real-part" n "number") (if (%number-type "complex" n) n.__re__ n))(define (make-polar r angle) "(make-polar magnitude angle) Create new complex number from polar parameters." (typecheck "make-polar" r "number") (typecheck "make-polar" angle "number") (if (or (complex? r) (complex? angle)) (error "make-polar: argument can't be complex") (let ((re (* r (sin angle))) (im (* r (cos angle)))) (make-rectangular im re))))(define (angle x) "(angle x) -Returns angle of the complex number in polar coordinate system." (if (not (complex? x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__)))(define (magnitude x) "(magnitude x) +Returns angle of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__)))(define (magnitude x) "(magnitude x) -Returns magnitude of the complex number in polar coordinate system." (if (not (complex? x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__)))))(define random (let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110)) (lambda new-seed "(random) +Returns magnitude of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__)))))(define random (let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110)) (lambda new-seed "(random) (random seed) Function generate new random real number using Knuth algorithm." (if (pair? new-seed) (set! seed (car new-seed)) (set! seed (modulo (+ (* seed a) c) m))) (exact->inexact (/ seed m)))))(define (eof-object? obj) "(eof-object? arg) @@ -705,4 +713,10 @@ Macro for defining records. Example of usage: ;; 1 (set-kdr! p 3) (print (kdr p)) -;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields)))))) \ No newline at end of file +;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields))))))(define +nan.0 NaN)(define -nan.0 NaN)(define (nan? x) "(nan? x) + +Function check if argument x is Not a Number (NaN) value." (or (eq? x NaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x))))))(define (infinite? x) "(infinite? x) + +Function check if value is infinite." (or (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (number? x) (not (eq? x NaN)) (%number-type "complex" x) (or (infinite? (real-part x)) (infinite? (imag-part x))))))(define (finite? x) "(finite? x) + +Function check if value is finite." (not (infinite? x))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index 8aca9ba1..dd4ac983 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1492,6 +1492,7 @@ ;; ----------------------------------------------------------------------------- (define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) + (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) @@ -1499,20 +1500,49 @@ (some typeof type) (typeof type))))) + ;; ----------------------------------------------------------------------------- -(define integer? (%doc - "" - (curry %number-type "bigint"))) +(define (real? x) + "(real? x) + + Function check if argument x is real." + (and (number? x) (or (eq? x NaN) + (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (and (%number-type "complex" x) (zero? (imag-part x))) + (%number-type '("float" "bigint" "rational") x)))) ;; ----------------------------------------------------------------------------- -(define complex? (%doc - "" - (curry %number-type "complex"))) +(define (integer? x) + "(integer? x) + + Function check if argument x is integer." + (and (number? x) + (not (eq? x NaN)) + (not (eq? x Number.NEGATIVE_INFINITY)) + (not (eq? x Number.POSITIVE_INFINITY)) + (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1))))) ;; ----------------------------------------------------------------------------- -(define rational? (%doc - "" - (curry %number-type '("rational" "bigint")))) +(define (complex? x) + "(complex? x) + + Function check if argument x is complex." + (and (number? x) (or (eq? x NaN) + (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (%number-type '("complex" "float" "bigint" "rational") x)))) + +;; ----------------------------------------------------------------------------- +(define (rational? x) + "(rational? x) + + Function check if value is rational." + (and (number? x) + (not (eq? x NaN)) + (not (eq? x Number.NEGATIVE_INFINITY)) + (not (eq? x Number.POSITIVE_INFINITY)) + (or (%number-type "rational" x) (integer? x)))) ;; ----------------------------------------------------------------------------- (define (typecheck-args _type name _list) @@ -1552,13 +1582,6 @@ (let ((value `((re . ,re) (im . ,im)))) (lips.LComplex (--> value (toObject true))))) -;; ----------------------------------------------------------------------------- -(define (real? n) - "(real? n)" - (and (number? n) (let ((type n.__type__)) - (or (string=? type "float") - (string=? type "bigint"))))) - ;; ----------------------------------------------------------------------------- (define (exact? n) "(exact? n)" @@ -1570,6 +1593,7 @@ (exact? n.__im__) (exact? n.__re__))))) +;; ----------------------------------------------------------------------------- (define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") @@ -1581,7 +1605,7 @@ Convert exact number to inexact." (typecheck "exact->inexact" n "number") - (if (complex? n) + (if (%number-type "complex" n) ;; make-object (&) will use valueOf so it will be float even if it was rational (lips.LComplex (object :im (. n 'im) :re (. n 're))) (if (or (rational? n) (integer? n)) @@ -1594,7 +1618,7 @@ Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") - (if (or (real? n) (complex? n)) + (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n)) @@ -2330,7 +2354,7 @@ Return imaginary part of the complex number n." (typecheck "imag-part" n "number") - (if (complex? n) + (if (%number-type "complex" n) n.__im__ 0)) @@ -2340,8 +2364,8 @@ Return real part of the complex number n." (typecheck "real-part" n "number") - (if (complex? n) - n.re + (if (%number-type "complex" n) + n.__re__ n)) ;; ----------------------------------------------------------------------------- @@ -2362,7 +2386,7 @@ "(angle x) Returns angle of the complex number in polar coordinate system." - (if (not (complex? x)) + (if (not (%number-type "complex" x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__))) @@ -2371,7 +2395,7 @@ "(magnitude x) Returns magnitude of the complex number in polar coordinate system." - (if (not (complex? x)) + (if (not (%number-type "complex" x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__))))) @@ -3501,3 +3525,37 @@ fields)))) ;; ----------------------------------------------------------------------------- +(define +nan.0 NaN) +(define -nan.0 NaN) + +;; ----------------------------------------------------------------------------- +(define (nan? x) + "(nan? x) + + Function check if argument x is Not a Number (NaN) value." + (or (eq? x NaN) + (and (%number-type "complex" x) + (or (nan? (real-part x)) + (nan? (imag-part x)))))) + +;; ----------------------------------------------------------------------------- +(define (infinite? x) + "(infinite? x) + + Function check if value is infinite." + (or (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (and (number? x) + (not (eq? x NaN)) + (%number-type "complex" x) + (or (infinite? (real-part x)) + (infinite? (imag-part x)))))) + +;; ----------------------------------------------------------------------------- +(define (finite? x) + "(finite? x) + + Function check if value is finite." + (not (infinite? x))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/R5RS.scm b/lib/R5RS.scm index a223a024..08421b26 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -265,6 +265,7 @@ ;; ----------------------------------------------------------------------------- (define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) + (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) @@ -272,20 +273,49 @@ (some typeof type) (typeof type))))) + ;; ----------------------------------------------------------------------------- -(define integer? (%doc - "" - (curry %number-type "bigint"))) +(define (real? x) + "(real? x) + + Function check if argument x is real." + (and (number? x) (or (eq? x NaN) + (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (and (%number-type "complex" x) (zero? (imag-part x))) + (%number-type '("float" "bigint" "rational") x)))) + +;; ----------------------------------------------------------------------------- +(define (integer? x) + "(integer? x) + + Function check if argument x is integer." + (and (number? x) + (not (eq? x NaN)) + (not (eq? x Number.NEGATIVE_INFINITY)) + (not (eq? x Number.POSITIVE_INFINITY)) + (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1))))) ;; ----------------------------------------------------------------------------- -(define complex? (%doc - "" - (curry %number-type "complex"))) +(define (complex? x) + "(complex? x) + + Function check if argument x is complex." + (and (number? x) (or (eq? x NaN) + (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (%number-type '("complex" "float" "bigint" "rational") x)))) ;; ----------------------------------------------------------------------------- -(define rational? (%doc - "" - (curry %number-type '("rational" "bigint")))) +(define (rational? x) + "(rational? x) + + Function check if value is rational." + (and (number? x) + (not (eq? x NaN)) + (not (eq? x Number.NEGATIVE_INFINITY)) + (not (eq? x Number.POSITIVE_INFINITY)) + (or (%number-type "rational" x) (integer? x)))) ;; ----------------------------------------------------------------------------- (define (typecheck-args _type name _list) @@ -325,13 +355,6 @@ (let ((value `((re . ,re) (im . ,im)))) (lips.LComplex (--> value (toObject true))))) -;; ----------------------------------------------------------------------------- -(define (real? n) - "(real? n)" - (and (number? n) (let ((type n.__type__)) - (or (string=? type "float") - (string=? type "bigint"))))) - ;; ----------------------------------------------------------------------------- (define (exact? n) "(exact? n)" @@ -343,6 +366,7 @@ (exact? n.__im__) (exact? n.__re__))))) +;; ----------------------------------------------------------------------------- (define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") @@ -354,7 +378,7 @@ Convert exact number to inexact." (typecheck "exact->inexact" n "number") - (if (complex? n) + (if (%number-type "complex" n) ;; make-object (&) will use valueOf so it will be float even if it was rational (lips.LComplex (object :im (. n 'im) :re (. n 're))) (if (or (rational? n) (integer? n)) @@ -367,7 +391,7 @@ Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") - (if (or (real? n) (complex? n)) + (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n)) @@ -1103,7 +1127,7 @@ Return imaginary part of the complex number n." (typecheck "imag-part" n "number") - (if (complex? n) + (if (%number-type "complex" n) n.__im__ 0)) @@ -1113,8 +1137,8 @@ Return real part of the complex number n." (typecheck "real-part" n "number") - (if (complex? n) - n.re + (if (%number-type "complex" n) + n.__re__ n)) ;; ----------------------------------------------------------------------------- @@ -1135,7 +1159,7 @@ "(angle x) Returns angle of the complex number in polar coordinate system." - (if (not (complex? x)) + (if (not (%number-type "complex" x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__))) @@ -1144,7 +1168,7 @@ "(magnitude x) Returns magnitude of the complex number in polar coordinate system." - (if (not (complex? x)) + (if (not (%number-type "complex" x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__))))) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index d01afcb7..dd5e1614 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -773,3 +773,37 @@ fields)))) ;; ----------------------------------------------------------------------------- +(define +nan.0 NaN) +(define -nan.0 NaN) + +;; ----------------------------------------------------------------------------- +(define (nan? x) + "(nan? x) + + Function check if argument x is Not a Number (NaN) value." + (or (eq? x NaN) + (and (%number-type "complex" x) + (or (nan? (real-part x)) + (nan? (imag-part x)))))) + +;; ----------------------------------------------------------------------------- +(define (infinite? x) + "(infinite? x) + + Function check if value is infinite." + (or (eq? x Number.NEGATIVE_INFINITY) + (eq? x Number.POSITIVE_INFINITY) + (and (number? x) + (not (eq? x NaN)) + (%number-type "complex" x) + (or (infinite? (real-part x)) + (infinite? (imag-part x)))))) + +;; ----------------------------------------------------------------------------- +(define (finite? x) + "(finite? x) + + Function check if value is finite." + (not (infinite? x))) + +;; ----------------------------------------------------------------------------- diff --git a/src/lips.js b/src/lips.js index 7c29522c..3dd372fa 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2865,6 +2865,12 @@ if (Number.isNaN(x)) { return Number.isNaN(y); } + if (x === Number.NEGATIVE_INFINITY) { + return y === Number.NEGATIVE_INFINITY; + } + if (x === Number.POSITIVE_INFINITY) { + return y === Number.POSITIVE_INFINITY; + } x = LNumber(x); y = LNumber(y); return x.__type__ === y.__type__ && x.cmp(y) === 0; @@ -7657,12 +7663,11 @@ Function check if value is real number.`), // ------------------------------------------------------------------ - 'number?': doc( - 'number?', - LNumber.isNumber, - `(number? expression) + 'number?': doc('number?', function(x) { + return Number.isNaN(x) || LNumber.isNumber(x); + }, `(number? expression) - Function check if value is a number`), + Function check if value is a number or NaN value.`), // ------------------------------------------------------------------ 'string?': doc('string?', function(obj) { return LString.isString(obj); diff --git a/tests/numbers.scm b/tests/numbers.scm index c4d9a8a1..d872279e 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -460,3 +460,37 @@ (t.is (eq? NaN NaN) true) (t.is (eq? 10 NaN) false) (t.is (eq? NaN 10) false))) + +(test "numbers: types" + (lambda (t) + (t.is (real? +nan.0) #t) + (t.is (rational? -inf.0) #f) + #;(t.is (rational? 3.5) #t) + (t.is (rational? 6/10) #t) + (t.is (rational? 6/3) #t) + (t.is (rational? 3.0) #t) + (t.is (integer? 3+0i) #t) + (t.is (integer? 3.0) #t) + (t.is (integer? 8/4) #t) + + (t.is (complex? 3+4i) #t) + (t.is (complex? 3) #t) + (t.is (real? 3) #t) + (t.is (real? -2.5+0i) #t) + (t.is (real? -2.5+0.0i) #t) + (t.is (real? #e1e10) #t) + (t.is (real? +inf.0) #t) + + (t.is (finite? 3) #t) + (t.is (finite? +inf.0) #f) + #;(t.is (finite? 3.0+inf.0i) #f) + + (t.is (infinite? 3) #f) + (t.is (infinite? +inf.0) #t) + (t.is (infinite? +nan.0) #f) + #;(t.is (infinite? 3.0+inf.0i) #t) + + (t.is (nan? +nan.0) #t) + (t.is (nan? 32) #f) + #;(t.is (nan? +nan.0+5.0i) #t) + (t.is (nan? 1+2i) #f))) From 403ad831127cce12c46818a406a1fe02d7de5134 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Feb 2021 14:07:49 +0100 Subject: [PATCH 038/109] fix parsing complex with 0 inexact imaginary part #34 --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 12 ++++++------ dist/lips.min.js | 4 ++-- dist/std.min.scm | 4 ++-- dist/std.scm | 8 ++++++-- lib/R5RS.scm | 8 ++++++-- src/lips.js | 10 +++++----- tests/numbers.scm | 7 ++++++- 9 files changed, 36 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ea2be02..5373b534 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * fix eq? and type of NaN [#130](https://github.com/jcubic/lips/issues/130) * fix number predicates * fix `real-part` function +* fix parsing complex with 0 inexact imaginary part ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index d4670359..65c8048a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&123a6479bfdb150dfeed5fb32005e88020fc6e3e)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&21f4261fd3cea6dc46e8366fa056c826)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&52ff387952789067b796ba1ab5998fa239d4d50a)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7fca85de60597a6ad6ff0ef1c6788ebf)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index b485297a..d64e8d94 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 12:17:30 +0000 + * build: Wed, 24 Feb 2021 13:06:06 +0000 */ (function () { 'use strict'; @@ -1715,7 +1715,7 @@ re = LNumber(0); } - if (im.cmp(0) === 0) { + if (im.cmp(0) === 0 && im.__type__ === 'bigint') { return re; } @@ -11239,7 +11239,7 @@ // ------------------------------------------------------------------ 'number?': doc('number?', function (x) { return Number.isNaN(x) || LNumber.isNumber(x); - }, "(number? expression)\n\n Function check if value is a number or NaN value."), + }, "(number? expression)\n\n Function check if value is a number or NaN value."), // ------------------------------------------------------------------ 'string?': doc('string?', function (obj) { return LString.isString(obj); @@ -13131,10 +13131,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 24 Feb 2021 12:17:30 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Feb 2021 13:06:06 +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('Wed, 24 Feb 2021 12:17:30 +0000').valueOf(); + var date = LString('Wed, 24 Feb 2021 13:06:06 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13174,7 +13174,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 24 Feb 2021 12:17:30 +0000', + date: 'Wed, 24 Feb 2021 13:06:06 +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 a5e2579f..83fe2ff3 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 12:17:30 +0000 + * build: Wed, 24 Feb 2021 13:06:06 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}else{u=LNumber(0)}if(o.cmp(0)===0){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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 12:17:30 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 12:17:30 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 13:06:06 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 13:06:06 +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,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/dist/std.min.scm b/dist/std.min.scm index 5856f2ae..a7692380 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -312,9 +312,9 @@ Return i element from vector." (typecheck "number->string" vector "array" 1) (ty Set obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj))(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type)))))(define (real? x) "(real? x) -Function check if argument x is real." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (%number-type "complex" x) (zero? (imag-part x))) (%number-type (quote ("float" "bigint" "rational")) x))))(define (integer? x) "(integer? x) +Function check if argument x is real." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (%number-type "complex" x) (let ((i (imag-part x))) (and (zero? i) (exact? i)))) (%number-type (quote ("float" "bigint" "rational")) x))))(define (integer? x) "(integer? x) -Function check if argument x is integer." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1)))))(define (complex? x) "(complex? x) +Function check if argument x is integer." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "bigint" x) (and (%number-type "float" x) (= (modulo x 2) 1)))))(define (complex? x) "(complex? x) Function check if argument x is complex." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (%number-type (quote ("complex" "float" "bigint" "rational")) x))))(define (rational? x) "(rational? x) diff --git a/dist/std.scm b/dist/std.scm index dd4ac983..f543d7dc 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1509,7 +1509,9 @@ (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) - (and (%number-type "complex" x) (zero? (imag-part x))) + (and (%number-type "complex" x) + (let ((i (imag-part x))) + (and (zero? i) (exact? i)))) (%number-type '("float" "bigint" "rational") x)))) ;; ----------------------------------------------------------------------------- @@ -1521,7 +1523,9 @@ (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) - (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1))))) + (or (%number-type "bigint" x) + (and (%number-type "float" x) + (= (modulo x 2) 1))))) ;; ----------------------------------------------------------------------------- (define (complex? x) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 08421b26..c03c8156 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -282,7 +282,9 @@ (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) - (and (%number-type "complex" x) (zero? (imag-part x))) + (and (%number-type "complex" x) + (let ((i (imag-part x))) + (and (zero? i) (exact? i)))) (%number-type '("float" "bigint" "rational") x)))) ;; ----------------------------------------------------------------------------- @@ -294,7 +296,9 @@ (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) - (or (%number-type "bigint" x) (and (real? x) (= (modulo x 2) 1))))) + (or (%number-type "bigint" x) + (and (%number-type "float" x) + (= (modulo x 2) 1))))) ;; ----------------------------------------------------------------------------- (define (complex? x) diff --git a/src/lips.js b/src/lips.js index 3dd372fa..53548380 100644 --- a/src/lips.js +++ b/src/lips.js @@ -436,7 +436,7 @@ } else { re = LNumber(0); } - if (im.cmp(0) === 0) { + if (im.cmp(0) === 0 && im.__type__ === 'bigint') { return re; } return LComplex({ im, re }); @@ -7663,11 +7663,11 @@ Function check if value is real number.`), // ------------------------------------------------------------------ - 'number?': doc('number?', function(x) { - return Number.isNaN(x) || LNumber.isNumber(x); - }, `(number? expression) + 'number?': doc('number?', function(x) { + return Number.isNaN(x) || LNumber.isNumber(x); + }, `(number? expression) - Function check if value is a number or NaN value.`), + Function check if value is a number or NaN value.`), // ------------------------------------------------------------------ 'string?': doc('string?', function(obj) { return LString.isString(obj); diff --git a/tests/numbers.scm b/tests/numbers.scm index d872279e..d8406159 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -477,7 +477,7 @@ (t.is (complex? 3) #t) (t.is (real? 3) #t) (t.is (real? -2.5+0i) #t) - (t.is (real? -2.5+0.0i) #t) + (t.is (real? -2.5+0.0i) #f) (t.is (real? #e1e10) #t) (t.is (real? +inf.0) #t) @@ -493,4 +493,9 @@ (t.is (nan? +nan.0) #t) (t.is (nan? 32) #f) #;(t.is (nan? +nan.0+5.0i) #t) + #;(t.is (nan? 5.0+nan.0i) #t) + #;(t.is (nan? +nan.0+nan.0i) #t) + #;(t.is (nan? -nan.0+5.0i) #t) + #;(t.is (nan? 5.0-nan.0i) #t) + #;(t.is (nan? -nan.0-nan.0i) #t) (t.is (nan? 1+2i) #f))) From 7b7c7023bda94db851cad9d582304607bdf607f6 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Feb 2021 16:41:50 +0100 Subject: [PATCH 039/109] refactor props for number types #118 Add __value__ for LNumber LFloat and LBigInteger Add __num__ and __denom__ for LRational --- README.md | 4 +- dist/lips.js | 168 +++++++++++++++++++++++++---------------------- dist/lips.min.js | 4 +- src/lips.js | 150 +++++++++++++++++++++--------------------- 4 files changed, 170 insertions(+), 156 deletions(-) diff --git a/README.md b/README.md index 65c8048a..62e2d233 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&52ff387952789067b796ba1ab5998fa239d4d50a)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7fca85de60597a6ad6ff0ef1c6788ebf)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&403ad831127cce12c46818a406a1fe02d7de5134)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&70025da025f64b988e51f0745ca5201e)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index d64e8d94..6028657d 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 13:06:06 +0000 + * build: Wed, 24 Feb 2021 15:38:30 +0000 */ (function () { 'use strict'; @@ -7211,9 +7211,9 @@ return LBigInteger(new BN(n)); } else if (parsable) { - this.value = parseInt(str, radix); + this.__value__ = parseInt(str, radix); } else { - this.value = n; + this.__value__ = n; } } // ------------------------------------------------------------------------- @@ -7348,10 +7348,10 @@ LNumber.prototype.toString = LNumber.prototype.toJSON = function (radix) { if (radix > 2 && radix < 36) { - return this.value.toString(radix); + return this.__value__.toString(radix); } - return this.value.toString(); + return this.__value__.toString(); }; // ------------------------------------------------------------------------- @@ -7363,14 +7363,14 @@ LNumber.prototype.isBigNumber = function () { - return typeof this.value === 'bigint' || typeof BN !== 'undefined' && !(this.value instanceof BN); + return typeof this.__value__ === 'bigint' || typeof BN !== 'undefined' && !(this.value instanceof BN); }; // ------------------------------------------------------------------------- ['floor', 'ceil', 'round'].forEach(function (fn) { LNumber.prototype[fn] = function () { - if (this["float"] || LNumber.isFloat(this.value)) { - return LNumber(Math[fn](this.value)); + if (this["float"] || LNumber.isFloat(this.__value__)) { + return LNumber(Math[fn](this.__value__)); } else { return LNumber(Math[fn](this.valueOf())); } @@ -7378,10 +7378,10 @@ }); // ------------------------------------------------------------------------- LNumber.prototype.valueOf = function () { - if (LNumber.isNative(this.value)) { - return Number(this.value); - } else if (LNumber.isBN(this.value)) { - return this.value.toNumber(); + if (LNumber.isNative(this.__value__)) { + return Number(this.__value__); + } else if (LNumber.isBN(this.__value__)) { + return this.__value__.toNumber(); } }; // ------------------------------------------------------------------------- @@ -7556,7 +7556,7 @@ LNumber.prototype.isFloat = function () { - return !!(LNumber.isFloat(this.value) || this["float"]); + return !!(LNumber.isFloat(this.__value__) || this["float"]); }; // ------------------------------------------------------------------------- @@ -7661,10 +7661,10 @@ LNumber.prototype.pow = function (n) { var value; - if (LNumber.isBN(this.value)) { - value = this.value.pow(n.value); + if (LNumber.isBN(this.__value__)) { + value = this.__value__.pow(n.__value__); } else { - value = pow(this.value, n.value); + value = pow(this.__value__, n.__value__); } return LNumber(value); @@ -7672,9 +7672,9 @@ LNumber.prototype.abs = function () { - var value = this.value; + var value = this.__value__; - if (LNumber.isNative(this.value)) { + if (LNumber.isNative(this.__value__)) { if (value < 0) { value = -value; } @@ -7687,14 +7687,14 @@ LNumber.prototype.isOdd = function () { - if (LNumber.isNative(this.value)) { + if (LNumber.isNative(this.__value__)) { if (this.isBigNumber()) { - return this.value % BigInt(2) === BigInt(1); + return this.__value__ % BigInt(2) === BigInt(1); } - return this.value % 2 === 1; - } else if (LNumber.isBN(this.value)) { - return this.value.isOdd(); + return this.__value__ % 2 === 1; + } else if (LNumber.isBN(this.__value__)) { + return this.__value__.isOdd(); } }; // ------------------------------------------------------------------------- @@ -7711,9 +7711,9 @@ b = _this$coerce4[1]; function cmp(a, b) { - if (a.value < b.value) { + if (a.__value__ < b.__value__) { return -1; - } else if (a.value === b.value) { + } else if (a.__value__ === b.__value__) { return 0; } else { return 1; @@ -7721,10 +7721,10 @@ } if (a.__type__ === 'bigint') { - if (LNumber.isNative(a.value)) { + if (LNumber.isNative(a.__value__)) { return cmp(a, b); - } else if (LNumber.isBN(a.value)) { - return this.value.cmp(b.value); + } else if (LNumber.isBN(a.__value__)) { + return this.__value__.cmp(b.__value__); } } else if (a instanceof LFloat) { return cmp(a, b); @@ -8014,7 +8014,7 @@ } if (typeof n === 'number') { - this.value = n; + this.__value__ = n; this.__type__ = 'float'; } } // ------------------------------------------------------------------------- @@ -8024,9 +8024,9 @@ LFloat.prototype.constructor = LFloat; // ------------------------------------------------------------------------- LFloat.prototype.toString = function () { - var str = this.value.toString(); + var str = this.__value__.toString(); - if (!LNumber.isFloat(this.value) && !str.match(/e/i)) { + if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { return str + '.0'; } @@ -8036,16 +8036,16 @@ LFloat.prototype._op = function (op, n) { if (n instanceof LNumber) { - n = n.value; + n = n.__value__; } var fn = LNumber._ops[op]; - if (op === '/' && this.value === 0 && n === 0) { + if (op === '/' && this.__value__ === 0 && n === 0) { return NaN; } - return LFloat(fn(this.value, n)); + return LFloat(fn(this.__value__, n)); }; // ------------------------------------------------------------------------- // same aproximation as in guile scheme @@ -8054,10 +8054,10 @@ var n = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : null; if (n === null) { - return toRational(this.value.valueOf()); + return toRational(this.__value__.valueOf()); } - return approxRatio(n.valueOf())(this.value.valueOf()); + return approxRatio(n.valueOf())(this.__value__.valueOf()); }; // ------------------------------------------------------------------------- // ref: https://rosettacode.org/wiki/Convert_decimal_number_to_rational // ------------------------------------------------------------------------- @@ -8152,8 +8152,8 @@ } } - this.num = num; - this.denom = denom; + this.__num__ = num; + this.__denom__ = denom; this.__type__ = 'rational'; } // ------------------------------------------------------------------------- @@ -8170,8 +8170,11 @@ if (cmp === -1) { n = n.sub(); - var num = this.denom.pow(n); - var denom = this.num.pow(n); + + var num = this.__denom__.pow(n); + + var denom = this.__num__.pow(n); + return LRational({ num: num, denom: denom @@ -8191,8 +8194,9 @@ LRational.prototype.sqrt = function () { - var num = this.num.sqrt(); - var denom = this.denom.sqrt(); + var num = this.__num__.sqrt(); + + var denom = this.__denom__.sqrt(); if (num instanceof LFloat) { num = (readOnlyError("num"), num.toRational()); @@ -8210,8 +8214,8 @@ LRational.prototype.abs = function () { - var num = this.num; - var denom = this.denom; + var num = this.__num__; + var denom = this.__denom__; if (num.cmp(0) === -1) { num = num.sub(); @@ -8234,24 +8238,25 @@ LRational.prototype.toString = function () { - var gcd = this.num.gcd(this.denom); + var gcd = this.__num__.gcd(this.__denom__); + var num, denom; if (gcd.cmp(1) !== 0) { - num = this.num.div(gcd); + num = this.__num__.div(gcd); if (num instanceof LRational) { num = LNumber(num.valueOf(true)); } - denom = this.denom.div(gcd); + denom = this.__denom__.div(gcd); if (denom instanceof LRational) { denom = LNumber(denom.valueOf(true)); } } else { - num = this.num; - denom = this.denom; + num = this.__num__; + denom = this.__denom__; } var minus = this.cmp(0) < 0; @@ -8269,8 +8274,8 @@ LRational.prototype.valueOf = function (exact) { - if (this.denom.cmp(0) === 0) { - if (this.num.cmp(0) < 0) { + if (this.__denom__.cmp(0) === 0) { + if (this.__num__.cmp(0) < 0) { return Number.NEGATIVE_INFINITY; } @@ -8278,10 +8283,10 @@ } if (exact) { - return LNumber._ops['/'](this.num.value, this.denom.value); + return LNumber._ops['/'](this.__num__.value, this.__denom__.value); } - return LFloat(this.num.valueOf()).div(this.denom.valueOf()); + return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf()); }; // ------------------------------------------------------------------------- @@ -8291,8 +8296,10 @@ } if (LNumber.isRational(n)) { - var num = this.num.mul(n.num); - var denom = this.denom.mul(n.denom); + var num = this.__num__.mul(n.__num__); + + var denom = this.__denom__.mul(n.__denom__); + return LRational({ num: num, denom: denom @@ -8314,8 +8321,10 @@ } if (LNumber.isRational(n)) { - var num = this.num.mul(n.denom); - var denom = this.denom.mul(n.num); + var num = this.__num__.mul(n.__denom__); + + var denom = this.__denom__.mul(n.__num__); + return LRational({ num: num, denom: denom @@ -8347,8 +8356,9 @@ } if (LNumber.isRational(n)) { - var num = n.num.sub(); - var denom = n.denom; + var num = n.__num__.sub(); + + var denom = n.__denom__; return this.add(LRational({ num: num, denom: denom @@ -8376,10 +8386,10 @@ } if (LNumber.isRational(n)) { - var a_denom = this.denom; - var b_denom = n.denom; - var a_num = this.num; - var b_num = n.num; + var a_denom = this.__denom__; + var b_denom = n.__denom__; + var a_num = this.__num__; + var b_num = n.__num__; var denom, num; if (a_denom !== b_denom) { @@ -8415,15 +8425,17 @@ } if (n instanceof LBigInteger) { - return LBigInteger(n.value, n._native); + return LBigInteger(n.__value__, n._native); } if (!LNumber.isBigInteger(n)) { throw new Error('Invalid constructor call for LBigInteger'); } - this.value = n; - this._native = _native2; + this.__value__ = n; + Object.defineProperty(this, '_native', { + value: _native2 + }); this.__type__ = 'bigint'; } // ------------------------------------------------------------------------- @@ -8446,20 +8458,20 @@ LBigInteger.prototype._op = function (op, n) { if (typeof n === 'undefined') { - if (LNumber.isBN(this.value)) { + if (LNumber.isBN(this.__value__)) { op = LBigInteger.bn_op[op]; - return LBigInteger(this.value.clone()[op](), false); + return LBigInteger(this.__value__.clone()[op](), false); } - return LBigInteger(LNumber._ops[op](this.value), true); + return LBigInteger(LNumber._ops[op](this.__value__), true); } - if (LNumber.isBN(this.value) && LNumber.isBN(n.value)) { + if (LNumber.isBN(this.__value__) && LNumber.isBN(n.__value__)) { op = LBigInteger.bn_op[op]; - return LBigInteger(this.value.clone()[op](n), false); + return LBigInteger(this.__value__.clone()[op](n), false); } - var ret = LNumber._ops[op](this.value, n.value); + var ret = LNumber._ops[op](this.__value__, n.__value__); if (op === '/') { var is_integer = this.op('%', n).cmp(0) === 0; @@ -8483,10 +8495,10 @@ var value; var minus = this.cmp(0) < 0; - if (LNumber.isNative(this.value)) { + if (LNumber.isNative(this.__value__)) { value = LNumber(Math.sqrt(minus ? -this.valueOf() : this.valueOf())); - } else if (LNumber.isBN(this.value)) { - value = minus ? this.value.neg().sqrt() : this.value.sqrt(); + } else if (LNumber.isBN(this.__value__)) { + value = minus ? this.__value__.neg().sqrt() : this.__value__.sqrt(); } if (minus) { @@ -13131,10 +13143,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 24 Feb 2021 13:06:06 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Feb 2021 15:38:30 +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('Wed, 24 Feb 2021 13:06:06 +0000').valueOf(); + var date = LString('Wed, 24 Feb 2021 15:38:30 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13174,7 +13186,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 24 Feb 2021 13:06:06 +0000', + date: 'Wed, 24 Feb 2021 15:38:30 +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 83fe2ff3..cea39912 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 13:06:06 +0000 + * build: Wed, 24 Feb 2021 15:38:30 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function _(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;classCallCheck(this,_);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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=r}})});this._whitespace=i;this._i=this._line=this._col=this._newline=0;this._state=this._next=this._token=null;this._prev_char=""}createClass(_,[{key:"get",value:function e(r){return this.__internal[r]}},{key:"set",value:function e(r,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var p;if(typeof f.__class__==="string"){p=f.__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")}}p=f.name}if(type(e)==="instance"&&!is_native_function(f)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var p=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.cont,s=c===void 0?function(){o.push.apply(o,toConsumableArray(p(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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var p=e.car.__name__;if(L["..."].symbols[p]&&!n.includes(p)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){A("NIL");L["..."].symbols[p]=nil}else{A("NULL");L["..."].symbols[p]=null}}else if(r instanceof Pair&&(r.car instanceof Pair||r.car===nil)){A(">> 3 "+t);if(t){if(L["..."].symbols[p]){var _=L["..."].symbols[p];if(_===nil){_=new Pair(nil,new Pair(r,nil))}else{_=_.append(new Pair(r,nil))}L["..."].symbols[p]=_}else{L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 4");L["..."].symbols[p]=new Pair(r,nil)}}else{A(">> 6");if(r instanceof Pair){A(">> 7 "+t);n.push(p);if(!L["..."].symbols[p]){L["..."].symbols[p]=new Pair(r,nil)}else{var h=L["..."].symbols[p];L["..."].symbols[p]=h.append(new Pair(r,nil))}A({IIIIII:L["..."].symbols[p].toString()})}else{A(">> 8");return false}}return true}else if(e.car instanceof Pair){var d=toConsumableArray(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var p=r[f];k({expr:e.toString(true),name:f,bindings:r,item:p});if(p===null){return}else if(p){k({b:r[f].toString()});if(p instanceof Pair){k("[t 2 Pair "+i);k({______:p.toString()});var _=p.car,h=p.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:_.toString()});return _}else{if(_.cdr!==nil){k("|| next 2");t(f,new Pair(_.cdr,h))}k({car:_.car.toString()});return _.car}}else if(p instanceof Array){k("[t 2 Array "+i);if(i){t(f,p.slice(1));return Pair.fromArray(p)}else{var d=p.slice(1);if(d.length){t(f,d)}return p[0]}}else{return p}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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 p=B(i.cdr.cdr,{disabled:r});return c.append(p)}return c}else{k(">> 3");var _=P(i.car,n,{nested:true});if(_){return new Pair(_,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 p=0;function _(){var e=new Pair(new LSymbol("begin"),r.cdr);return evaluate(e,{env:s,dynamic_scope:a,error:u})}return function r(){var n=o[p++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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 p=BigInt(c);i=toConsumableArray(o).map(function(e,r){return BigInt(parseInt(e,c))*Math.pow(p,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(t){this.value=parseInt(o,c)}else{this.value=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__im__.coerce(i.__im__),f=slicedToArray(l,2),p=f[0],_=f[1];return p.cmp(_)}};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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.value=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.value.toString();if(!LNumber.isFloat(this.value)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.value}var n=LNumber._ops[e];if(e==="/"&&this.value===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.num=n;this.denom=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.denom.pow(e);var t=this.num.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.num.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.denom.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.num;n=this.denom}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.denom.mul(e.denom);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.denom.mul(e.num);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.denom;var t=this.num;var i=e.num;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.value=e;this._native=r;this.__type__="bigint"}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 n=LNumber._ops[e](this.value,r.value);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var p=evaluate(l,{env:this,dynamic_scope:n,error:t});return c(f,p,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 _=e.car.valueOf();u=this.ref(e.car.__name__);return unpromise(o,function(e){if(!u){var r=_.split(".");if(r.length>1){var n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,e);return}}throw new Error("Unbound variable `"+_+"'")}u.set(_,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.cdr.cdr;if(l!==nil){l=new Pair(LSymbol("begin"),l)}f={env:u,dynamic_scope:i,error:a};p=c;case 10:if(!(p!==nil)){r.next=21;break}_=p.car;r.t0=o;r.t1=_.car;r.next=16;return evaluate(_.cdr.car,f);case 16:r.t2=r.sent;r.t0.set.call(r.t0,r.t1,r.t2);p=p.cdr;r.next=10;break;case 21:f={env:o,dynamic_scope:i,error:a};h=regenerator.mark(function e(){var n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},p=e.dynamic_scope,_=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(p){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return _(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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"),_(i,r+2,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return p(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 p=n.get(Symbol["for"]("__promise__"),{throwError:false});if(p===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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}p=f;_=evaluate(p,{env:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.toString(true))}}throw r}});if(is_promise(_)){r.next=20;break}a.push(_);r.next=25;break;case 20:r.t0=a;r.next=23;return _;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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 13:06:06 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 13:06:06 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){this.__value__=parseInt(o,c)}else{this.__value__=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.__value__=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.__num__=n;this.__denom__=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.__value__=e;Object.defineProperty(this,"_native",{value:r});this.__type__="bigint"}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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 15:38:30 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 15:38:30 +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,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/src/lips.js b/src/lips.js index 53548380..c716ad1c 100644 --- a/src/lips.js +++ b/src/lips.js @@ -4422,9 +4422,9 @@ } return LBigInteger(new BN(n)); } else if (parsable) { - this.value = parseInt(str, radix); + this.__value__ = parseInt(str, radix); } else { - this.value = n; + this.__value__ = n; } } // ------------------------------------------------------------------------- @@ -4528,9 +4528,9 @@ // ------------------------------------------------------------------------- LNumber.prototype.toString = LNumber.prototype.toJSON = function(radix) { if (radix > 2 && radix < 36) { - return this.value.toString(radix); + return this.__value__.toString(radix); } - return this.value.toString(); + return this.__value__.toString(); }; // ------------------------------------------------------------------------- LNumber.prototype.asType = function(n) { @@ -4539,14 +4539,14 @@ }; // ------------------------------------------------------------------------- LNumber.prototype.isBigNumber = function() { - return typeof this.value === 'bigint' || + return typeof this.__value__ === 'bigint' || typeof BN !== 'undefined' && !(this.value instanceof BN); }; // ------------------------------------------------------------------------- ['floor', 'ceil', 'round'].forEach(fn => { LNumber.prototype[fn] = function() { - if (this.float || LNumber.isFloat(this.value)) { - return LNumber(Math[fn](this.value)); + if (this.float || LNumber.isFloat(this.__value__)) { + return LNumber(Math[fn](this.__value__)); } else { return LNumber(Math[fn](this.valueOf())); } @@ -4554,10 +4554,10 @@ }); // ------------------------------------------------------------------------- LNumber.prototype.valueOf = function() { - if (LNumber.isNative(this.value)) { - return Number(this.value); - } else if (LNumber.isBN(this.value)) { - return this.value.toNumber(); + if (LNumber.isNative(this.__value__)) { + return Number(this.__value__); + } else if (LNumber.isBN(this.__value__)) { + return this.__value__.toNumber(); } }; // ------------------------------------------------------------------------- @@ -4677,7 +4677,7 @@ }; // ------------------------------------------------------------------------- LNumber.prototype.isFloat = function() { - return !!(LNumber.isFloat(this.value) || this.float); + return !!(LNumber.isFloat(this.__value__) || this.float); }; // ------------------------------------------------------------------------- var mapping = { @@ -4762,17 +4762,17 @@ // ------------------------------------------------------------------------- LNumber.prototype.pow = function(n) { var value; - if (LNumber.isBN(this.value)) { - value = this.value.pow(n.value); + if (LNumber.isBN(this.__value__)) { + value = this.__value__.pow(n.__value__); } else { - value = pow(this.value, n.value); + value = pow(this.__value__, n.__value__); } return LNumber(value); }; // ------------------------------------------------------------------------- LNumber.prototype.abs = function() { - var value = this.value; - if (LNumber.isNative(this.value)) { + var value = this.__value__; + if (LNumber.isNative(this.__value__)) { if (value < 0) { value = -value; } @@ -4783,13 +4783,13 @@ }; // ------------------------------------------------------------------------- LNumber.prototype.isOdd = function() { - if (LNumber.isNative(this.value)) { + if (LNumber.isNative(this.__value__)) { if (this.isBigNumber()) { - return this.value % BigInt(2) === BigInt(1); + return this.__value__ % BigInt(2) === BigInt(1); } - return this.value % 2 === 1; - } else if (LNumber.isBN(this.value)) { - return this.value.isOdd(); + return this.__value__ % 2 === 1; + } else if (LNumber.isBN(this.__value__)) { + return this.__value__.isOdd(); } }; // ------------------------------------------------------------------------- @@ -4800,19 +4800,19 @@ LNumber.prototype.cmp = function(n) { const [a, b] = this.coerce(n); function cmp(a, b) { - if (a.value < b.value) { + if (a.__value__ < b.__value__) { return -1; - } else if (a.value === b.value) { + } else if (a.__value__ === b.__value__) { return 0; } else { return 1; } } if (a.__type__ === 'bigint') { - if (LNumber.isNative(a.value)) { + if (LNumber.isNative(a.__value__)) { return cmp(a, b); - } else if (LNumber.isBN(a.value)) { - return this.value.cmp(b.value); + } else if (LNumber.isBN(a.__value__)) { + return this.__value__.cmp(b.__value__); } } else if (a instanceof LFloat) { return cmp(a, b); @@ -5021,7 +5021,7 @@ return LFloat(n.valueOf()); } if (typeof n === 'number') { - this.value = n; + this.__value__ = n; this.__type__ = 'float'; } } @@ -5030,8 +5030,8 @@ LFloat.prototype.constructor = LFloat; // ------------------------------------------------------------------------- LFloat.prototype.toString = function() { - var str = this.value.toString(); - if (!LNumber.isFloat(this.value) && !str.match(/e/i)) { + var str = this.__value__.toString(); + if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { return str + '.0'; } return str.replace(/^([0-9]+)e/, '$1.0e'); @@ -5039,21 +5039,21 @@ // ------------------------------------------------------------------------- LFloat.prototype._op = function(op, n) { if (n instanceof LNumber) { - n = n.value; + n = n.__value__; } const fn = LNumber._ops[op]; - if (op === '/' && this.value === 0 && n === 0) { + if (op === '/' && this.__value__ === 0 && n === 0) { return NaN; } - return LFloat(fn(this.value, n), true); + return LFloat(fn(this.__value__, n), true); }; // ------------------------------------------------------------------------- // same aproximation as in guile scheme LFloat.prototype.toRational = function(n = null) { if (n === null) { - return toRational(this.value.valueOf()); + return toRational(this.__value__.valueOf()); } - return approxRatio(n.valueOf())(this.value.valueOf()); + return approxRatio(n.valueOf())(this.__value__.valueOf()); }; // ------------------------------------------------------------------------- // ref: https://rosettacode.org/wiki/Convert_decimal_number_to_rational @@ -5126,8 +5126,8 @@ return LNumber(num.div(denom)); } } - this.num = num; - this.denom = denom; + this.__num__ = num; + this.__denom__ = denom; this.__type__ = 'rational'; } // ------------------------------------------------------------------------- @@ -5141,8 +5141,8 @@ } if (cmp === -1) { n = n.sub(); - var num = this.denom.pow(n); - var denom = this.num.pow(n); + var num = this.__denom__.pow(n); + var denom = this.__num__.pow(n); return LRational({ num, denom }); } var result = this; @@ -5155,8 +5155,8 @@ }; // ------------------------------------------------------------------------- LRational.prototype.sqrt = function() { - const num = this.num.sqrt(); - const denom = this.denom.sqrt(); + const num = this.__num__.sqrt(); + const denom = this.__denom__.sqrt(); if (num instanceof LFloat) { num = num.toRational(); } @@ -5167,8 +5167,8 @@ }; // ------------------------------------------------------------------------- LRational.prototype.abs = function() { - var num = this.num; - var denom = this.denom; + var num = this.__num__; + var denom = this.__denom__; if (num.cmp(0) === -1) { num = num.sub(); } @@ -5183,20 +5183,20 @@ }; // ------------------------------------------------------------------------- LRational.prototype.toString = function() { - var gcd = this.num.gcd(this.denom); + var gcd = this.__num__.gcd(this.__denom__); var num, denom; if (gcd.cmp(1) !== 0) { - num = this.num.div(gcd); + num = this.__num__.div(gcd); if (num instanceof LRational) { num = LNumber(num.valueOf(true)); } - denom = this.denom.div(gcd); + denom = this.__denom__.div(gcd); if (denom instanceof LRational) { denom = LNumber(denom.valueOf(true)); } } else { - num = this.num; - denom = this.denom; + num = this.__num__; + denom = this.__denom__; } const minus = this.cmp(0) < 0; if (minus) { @@ -5210,16 +5210,16 @@ }; // ------------------------------------------------------------------------- LRational.prototype.valueOf = function(exact) { - if (this.denom.cmp(0) === 0) { - if (this.num.cmp(0) < 0) { + if (this.__denom__.cmp(0) === 0) { + if (this.__num__.cmp(0) < 0) { return Number.NEGATIVE_INFINITY; } return Number.POSITIVE_INFINITY; } if (exact) { - return LNumber._ops['/'](this.num.value, this.denom.value); + return LNumber._ops['/'](this.__num__.value, this.__denom__.value); } - return LFloat(this.num.valueOf()).div(this.denom.valueOf()); + return LFloat(this.__num__.valueOf()).div(this.__denom__.valueOf()); }; // ------------------------------------------------------------------------- LRational.prototype.mul = function(n) { @@ -5227,8 +5227,8 @@ n = LNumber(n); // handle (--> 1/2 (mul 2)) } if (LNumber.isRational(n)) { - var num = this.num.mul(n.num); - var denom = this.denom.mul(n.denom); + var num = this.__num__.mul(n.__num__); + var denom = this.__denom__.mul(n.__denom__); return LRational({ num, denom }); } const [a, b] = LNumber.coerce(this, n); @@ -5240,8 +5240,8 @@ n = LNumber(n); // handle (--> 1/2 (div 2)) } if (LNumber.isRational(n)) { - var num = this.num.mul(n.denom); - var denom = this.denom.mul(n.num); + var num = this.__num__.mul(n.__denom__); + var denom = this.__denom__.mul(n.__num__); return LRational({ num, denom }); } const [a, b] = LNumber.coerce(this, n); @@ -5261,8 +5261,8 @@ n = LNumber(n); // handle (--> 1/2 (sub 1)) } if (LNumber.isRational(n)) { - var num = n.num.sub(); - var denom = n.denom; + var num = n.__num__.sub(); + var denom = n.__denom__; return this.add(LRational({ num, denom })); } if (!(n instanceof LNumber)) { @@ -5279,10 +5279,10 @@ n = LNumber(n); // handle (--> 1/2 (add 1)) } if (LNumber.isRational(n)) { - const a_denom = this.denom; - const b_denom = n.denom; - const a_num = this.num; - const b_num = n.num; + const a_denom = this.__denom__; + const b_denom = n.__denom__; + const a_num = this.__num__; + const b_num = n.__num__; let denom, num; if (a_denom !== b_denom) { num = b_denom.mul(a_num).add(b_num.mul(a_denom)); @@ -5306,13 +5306,15 @@ return new LBigInteger(n, native); } if (n instanceof LBigInteger) { - return LBigInteger(n.value, n._native); + return LBigInteger(n.__value__, n._native); } if (!LNumber.isBigInteger(n)) { throw new Error('Invalid constructor call for LBigInteger'); } - this.value = n; - this._native = native; + this.__value__ = n; + Object.defineProperty(this, '_native', { + value: native + }); this.__type__ = 'bigint'; } // ------------------------------------------------------------------------- @@ -5334,17 +5336,17 @@ // ------------------------------------------------------------------------- LBigInteger.prototype._op = function(op, n) { if (typeof n === 'undefined') { - if (LNumber.isBN(this.value)) { + if (LNumber.isBN(this.__value__)) { op = LBigInteger.bn_op[op]; - return LBigInteger(this.value.clone()[op](), false); + return LBigInteger(this.__value__.clone()[op](), false); } - return LBigInteger(LNumber._ops[op](this.value), true); + return LBigInteger(LNumber._ops[op](this.__value__), true); } - if (LNumber.isBN(this.value) && LNumber.isBN(n.value)) { + if (LNumber.isBN(this.__value__) && LNumber.isBN(n.__value__)) { op = LBigInteger.bn_op[op]; - return LBigInteger(this.value.clone()[op](n), false); + return LBigInteger(this.__value__.clone()[op](n), false); } - const ret = LNumber._ops[op](this.value, n.value); + const ret = LNumber._ops[op](this.__value__, n.__value__); if (op === '/') { var is_integer = this.op('%', n).cmp(0) === 0; if (is_integer) { @@ -5359,10 +5361,10 @@ LBigInteger.prototype.sqrt = function() { var value; var minus = this.cmp(0) < 0; - if (LNumber.isNative(this.value)) { + if (LNumber.isNative(this.__value__)) { value = LNumber(Math.sqrt(minus ? -this.valueOf() : this.valueOf())); - } else if (LNumber.isBN(this.value)) { - value = minus ? this.value.neg().sqrt() : this.value.sqrt(); + } else if (LNumber.isBN(this.__value__)) { + value = minus ? this.__value__.neg().sqrt() : this.__value__.sqrt(); } if (minus) { return LComplex({ re: 0, im: value }); From bd78bc57bbb8b464fe7d95690ff4f8a012809946 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Wed, 24 Feb 2021 17:30:26 +0100 Subject: [PATCH 040/109] make numbers and characters immutable #131 --- CHANGELOG.md | 1 + README.md | 4 +- dist/lips.js | 126 +++++++++++++++++++++++++++++++++------------- dist/lips.min.js | 4 +- src/lips.js | 104 +++++++++++++++++++++++++++----------- tests/numbers.scm | 1 - 6 files changed, 171 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5373b534..1402f750 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Breaking * `env` and `dir` now returns symbols instead of strings * `repr` and `type` of quoted promises now return `#` and `promise` +* numbers and characters properties are immutable ### Features * create minfied std scheme file for faster bootstrap * add `list-copy` diff --git a/README.md b/README.md index 62e2d233..f708a40b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&403ad831127cce12c46818a406a1fe02d7de5134)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&70025da025f64b988e51f0745ca5201e)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&7b7c7023bda94db851cad9d582304607bdf607f6)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&62dbf340625df0760a1453bcecbd3907)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 6028657d..82cc6b03 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 15:38:30 +0000 + * build: Wed, 24 Feb 2021 16:22:48 +0000 */ (function () { 'use strict'; @@ -6918,34 +6918,43 @@ // ------------------------------------------------------------------------- - function LCharacter(chr) { + function LCharacter(_char7) { if (typeof this !== 'undefined' && !(this instanceof LCharacter) || typeof this === 'undefined') { - return new LCharacter(chr); + return new LCharacter(_char7); } - if (chr instanceof LString) { - chr = chr.valueOf(); + if (_char7 instanceof LString) { + _char7 = _char7.valueOf(); } - if (Array.from(chr).length > 1) { + var name; + + if (Array.from(_char7).length > 1) { // this is name - chr = chr.toLowerCase(); + _char7 = _char7.toLowerCase(); - if (LCharacter.__names__[chr]) { - this.__name__ = chr; - this.__char__ = LCharacter.__names__[chr]; + if (LCharacter.__names__[_char7]) { + name = _char7; + _char7 = LCharacter.__names__[_char7]; } else { // this should never happen // parser don't alow not defined named characters throw new Error('Internal: Unknown named character'); } } else { - this.__char__ = chr; - var name = LCharacter.__rev_names__[chr]; + name = LCharacter.__rev_names__[_char7]; + } - if (name) { - this.__name__ = name; - } + Object.defineProperty(this, '__char__', { + value: _char7, + enumerable: true + }); + + if (name) { + Object.defineProperty(this, '__name__', { + value: name, + enumerable: true + }); } } @@ -7052,9 +7061,9 @@ return LString(this.__string__.toUpperCase()); }; - LString.prototype.set = function (n, _char7) { - if (_char7 instanceof LCharacter) { - _char7 = _char7.__char__; + LString.prototype.set = function (n, _char8) { + if (_char8 instanceof LCharacter) { + _char8 = _char8.__char__; } var string = []; @@ -7063,7 +7072,7 @@ string.push(this.__string__.substring(0, n)); } - string.push(_char7); + string.push(_char8); if (n < this.__string__.length - 1) { string.push(this.__string__.substring(n + 1)); @@ -7211,13 +7220,25 @@ return LBigInteger(new BN(n)); } else if (parsable) { - this.__value__ = parseInt(str, radix); + this.constant(parseInt(str, radix), 'integer'); } else { - this.__value__ = n; + this.constant(n, 'integer'); } } // ------------------------------------------------------------------------- + LNumber.prototype.constant = function (value, type) { + Object.defineProperty(this, '__value__', { + value: value, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: type, + enumerable: true + }); + }; // ------------------------------------------------------------------------- + + LNumber.types = { "float": function float(n) { var force = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : false; @@ -7758,15 +7779,29 @@ var im = n.im instanceof LNumber ? n.im : LNumber(n.im); var re = n.re instanceof LNumber ? n.re : LNumber(n.re); - this.__im__ = im; - this.__re__ = re; - this.__type__ = 'complex'; + this.constant(im, re); } // ------------------------------------------------------------------------- LComplex.prototype = Object.create(LNumber.prototype); LComplex.prototype.constructor = LComplex; // ------------------------------------------------------------------------- + LComplex.prototype.constant = function (im, re) { + Object.defineProperty(this, '__im__', { + value: im, + enumerable: true + }); + Object.defineProperty(this, '__re__', { + value: re, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: 'complex', + enumerable: true + }); + }; // ------------------------------------------------------------------------- + + LComplex.prototype.toRational = function (n) { if (LNumber.isFloat(this.__im__) && LNumber.isFloat(this.__re__)) { var im = LFloat(this.__im__).toRational(n); @@ -8014,8 +8049,7 @@ } if (typeof n === 'number') { - this.__value__ = n; - this.__type__ = 'float'; + this.constant(n, 'float'); } } // ------------------------------------------------------------------------- @@ -8141,8 +8175,15 @@ throw new Error('Invalid constructor call for LRational'); } - var num = LNumber(n.num); - var denom = LNumber(n.denom); + var num, denom; + + if (n instanceof LRational) { + num = LNumber(n.__num__); + denom = LNumber(n.__denom__); + } else { + num = LNumber(n.num); + denom = LNumber(n.denom); + } if (!force && denom.cmp(0) !== 0) { var is_integer = num.op('%', denom).cmp(0) === 0; @@ -8152,15 +8193,29 @@ } } - this.__num__ = num; - this.__denom__ = denom; - this.__type__ = 'rational'; + this.constant(num, denom); } // ------------------------------------------------------------------------- LRational.prototype = Object.create(LNumber.prototype); LRational.prototype.constructor = LRational; // ------------------------------------------------------------------------- + LRational.prototype.constant = function (num, denom) { + Object.defineProperty(this, '__num__', { + value: num, + enumerable: true + }); + Object.defineProperty(this, '__denom__', { + value: denom, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: 'rational', + enumerable: true + }); + }; // ------------------------------------------------------------------------- + + LRational.prototype.pow = function (n) { var cmp = n.cmp(0); @@ -8432,11 +8487,10 @@ throw new Error('Invalid constructor call for LBigInteger'); } - this.__value__ = n; + this.constant(n, 'bigint'); Object.defineProperty(this, '_native', { value: _native2 }); - this.__type__ = 'bigint'; } // ------------------------------------------------------------------------- @@ -13143,10 +13197,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 24 Feb 2021 15:38:30 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 24 Feb 2021 16:22:48 +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('Wed, 24 Feb 2021 15:38:30 +0000').valueOf(); + var date = LString('Wed, 24 Feb 2021 16:22:48 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13186,7 +13240,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 24 Feb 2021 15:38:30 +0000', + date: 'Wed, 24 Feb 2021 16:22:48 +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 cea39912..6b1fad66 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 15:38:30 +0000 + * build: Wed, 24 Feb 2021 16:22:48 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){e=e.toLowerCase();if(LCharacter.__names__[e]){this.__name__=e;this.__char__=LCharacter.__names__[e]}else{throw new Error("Internal: Unknown named character")}}else{this.__char__=e;var r=LCharacter.__rev_names__[e];if(r){this.__name__=r}}}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){this.__value__=parseInt(o,c)}else{this.__value__=e}}LNumber.types={float:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.__im__=n;this.__re__=t;this.__type__="complex"}LComplex.prototype=Object.create(LNumber.prototype);LComplex.prototype.constructor=LComplex;LComplex.prototype.toRational=function(e){if(LNumber.isFloat(this.__im__)&&LNumber.isFloat(this.__re__)){var r=LFloat(this.__im__).toRational(e);var n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.__value__=e;this.__type__="float"}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n=LNumber(e.num);var t=LNumber(e.denom);if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.__num__=n;this.__denom__=t;this.__type__="rational"}LRational.prototype=Object.create(LNumber.prototype);LRational.prototype.constructor=LRational;LRational.prototype.pow=function(e){var r=e.cmp(0);if(r===0){return LNumber(1)}if(r===-1){e=e.sub();var n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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.__value__=e;Object.defineProperty(this,"_native",{value:r});this.__type__="bigint"}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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 15:38:30 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 15:38:30 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 16:22:48 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 16:22:48 +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,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/src/lips.js b/src/lips.js index c716ad1c..a9c97bc4 100644 --- a/src/lips.js +++ b/src/lips.js @@ -4203,31 +4203,38 @@ // ------------------------------------------------------------------------- // :: character object representation // ------------------------------------------------------------------------- - function LCharacter(chr) { + function LCharacter(char) { if (typeof this !== 'undefined' && !(this instanceof LCharacter) || typeof this === 'undefined') { - return new LCharacter(chr); + return new LCharacter(char); } - if (chr instanceof LString) { - chr = chr.valueOf(); + if (char instanceof LString) { + char = char.valueOf(); } - if (Array.from(chr).length > 1) { + var name; + if (Array.from(char).length > 1) { // this is name - chr = chr.toLowerCase(); - if (LCharacter.__names__[chr]) { - this.__name__ = chr; - this.__char__ = LCharacter.__names__[chr]; + char = char.toLowerCase(); + if (LCharacter.__names__[char]) { + name = char; + char = LCharacter.__names__[char]; } else { // this should never happen // parser don't alow not defined named characters throw new Error('Internal: Unknown named character'); } } else { - this.__char__ = chr; - const name = LCharacter.__rev_names__[chr]; - if (name) { - this.__name__ = name; - } + name = LCharacter.__rev_names__[char]; + } + Object.defineProperty(this, '__char__', { + value: char, + enumerable: true + }); + if (name) { + Object.defineProperty(this, '__name__', { + value: name, + enumerable: true + }); } } LCharacter.__names__ = characters; @@ -4422,12 +4429,23 @@ } return LBigInteger(new BN(n)); } else if (parsable) { - this.__value__ = parseInt(str, radix); + this.constant(parseInt(str, radix), 'integer'); } else { - this.__value__ = n; + this.constant(n, 'integer'); } } // ------------------------------------------------------------------------- + LNumber.prototype.constant = function(value, type) { + Object.defineProperty(this, '__value__', { + value, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: type, + enumerable: true + }); + }; + // ------------------------------------------------------------------------- LNumber.types = { float: function(n, force = false) { return new LFloat(n, force); @@ -4838,14 +4856,27 @@ } var im = n.im instanceof LNumber ? n.im : LNumber(n.im); var re = n.re instanceof LNumber ? n.re : LNumber(n.re); - this.__im__ = im; - this.__re__ = re; - this.__type__ = 'complex'; + this.constant(im, re); } // ------------------------------------------------------------------------- LComplex.prototype = Object.create(LNumber.prototype); LComplex.prototype.constructor = LComplex; // ------------------------------------------------------------------------- + LComplex.prototype.constant = function(im, re) { + Object.defineProperty(this, '__im__', { + value: im, + enumerable: true + }); + Object.defineProperty(this, '__re__', { + value: re, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: 'complex', + enumerable: true + }); + }; + // ------------------------------------------------------------------------- LComplex.prototype.toRational = function(n) { if (LNumber.isFloat(this.__im__) && LNumber.isFloat(this.__re__)) { const im = LFloat(this.__im__).toRational(n); @@ -5021,8 +5052,7 @@ return LFloat(n.valueOf()); } if (typeof n === 'number') { - this.__value__ = n; - this.__type__ = 'float'; + this.constant(n, 'float'); } } // ------------------------------------------------------------------------- @@ -5118,22 +5148,41 @@ if (!LNumber.isRational(n)) { throw new Error('Invalid constructor call for LRational'); } - var num = LNumber(n.num); - var denom = LNumber(n.denom); + var num, denom; + if (n instanceof LRational) { + num = LNumber(n.__num__); + denom = LNumber(n.__denom__); + } else { + num = LNumber(n.num); + denom = LNumber(n.denom); + } if (!force && denom.cmp(0) !== 0) { var is_integer = num.op('%', denom).cmp(0) === 0; if (is_integer) { return LNumber(num.div(denom)); } } - this.__num__ = num; - this.__denom__ = denom; - this.__type__ = 'rational'; + this.constant(num, denom); } // ------------------------------------------------------------------------- LRational.prototype = Object.create(LNumber.prototype); LRational.prototype.constructor = LRational; // ------------------------------------------------------------------------- + LRational.prototype.constant = function(num, denom) { + Object.defineProperty(this, '__num__', { + value: num, + enumerable: true + }); + Object.defineProperty(this, '__denom__', { + value: denom, + enumerable: true + }); + Object.defineProperty(this, '__type__', { + value: 'rational', + enumerable: true + }); + }; + // ------------------------------------------------------------------------- LRational.prototype.pow = function(n) { var cmp = n.cmp(0); if (cmp === 0) { @@ -5311,11 +5360,10 @@ if (!LNumber.isBigInteger(n)) { throw new Error('Invalid constructor call for LBigInteger'); } - this.__value__ = n; + this.constant(n, 'bigint'); Object.defineProperty(this, '_native', { value: native }); - this.__type__ = 'bigint'; } // ------------------------------------------------------------------------- LBigInteger.prototype = Object.create(LNumber.prototype); diff --git a/tests/numbers.scm b/tests/numbers.scm index d8406159..3d7f0695 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -15,7 +15,6 @@ (test "numbers: complex rational" (lambda (t) - (t.is (/ (make-rectangular 1 2) (make-rectangular 2 10)) (/ 1+2i 2+10i)))) From 40561b18336db72655b139f95f4f685f29185732 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 25 Feb 2021 09:29:03 +0100 Subject: [PATCH 041/109] fix option -t --trace in Node REPL The -c option didn't showed stack trace it do that by default Interactive REPL now accept -t and --trace option it was not used --- bin/lips.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/lips.js b/bin/lips.js index be989740..2fd6320c 100755 --- a/bin/lips.js +++ b/bin/lips.js @@ -243,7 +243,7 @@ if (options.version || options.V) { bootstrap(interp).then(function() { const code = options.e || options.eval || options.c || options.code; const dynamic = options.d || options.dynamic; - return run(code, interp, dynamic).then(print); + return run(code, interp, dynamic, null, true).then(print); }); } else if (options._.length >= 1) { // hack for node-gtk @@ -373,7 +373,7 @@ function run_repl(err, rl) { rl.setPrompt(''); rl.pause(); prev_eval = prev_eval.then(function() { - var result = run(code, interp, dynamic); + var result = run(code, interp, dynamic, null, options.t || options.trace); code = ''; return result; }).then(function(result) { From f6b55d30781fab1f447422df82798d455359db1f Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 25 Feb 2021 12:22:30 +0100 Subject: [PATCH 042/109] change eqv? and add negative zero eqv? no handle exact and inexact numbers differently - it changed LIPS signature --- CHANGELOG.md | 3 +++ README.md | 4 +-- dist/lips.js | 54 +++++++++++++++++++++++--------------- dist/lips.min.js | 4 +-- dist/std.min.scm | 2 +- dist/std.scm | 8 +++++- examples/scheme-detect.scm | 18 +++++++------ lib/R5RS.scm | 8 +++++- src/lips.js | 44 +++++++++++++++++++------------ tests/numbers.scm | 40 +++++++++++++++++++++++----- 10 files changed, 126 insertions(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1402f750..a8a72cfd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * automatic bootstrapping of `fs` with BrowserFS if exists * `pprint` in both REPLs now print in color [#33](https://github.com/jcubic/lips/issues/33) * add `nan?`, `infinite?` and `finite?` functions +* properly handle negative inexact zero ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string @@ -26,6 +27,8 @@ * fix number predicates * fix `real-part` function * fix parsing complex with 0 inexact imaginary part +* fix option -t --trace in Node REPL +* fix `eqv?` on exact and inexact numbers according to R7RS spec ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index f708a40b..630c219e 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&7b7c7023bda94db851cad9d582304607bdf607f6)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&62dbf340625df0760a1453bcecbd3907)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&951f1cd48fca27eea19082b8897fe6543f382903)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7edfa491b886ec9837f1c5b09220eccf)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 82cc6b03..72c899e0 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 16:22:48 +0000 + * build: Thu, 25 Feb 2021 11:23:00 +0000 */ (function () { 'use strict'; @@ -5086,7 +5086,13 @@ _type3 = true; } - return _type3 && x.cmp(y) === 0; + if (_type3 && x.cmp(y) === 0) { + if (x.valueOf() === 0) { + return Object.is(x.valueOf(), y.valueOf()); + } + + return true; + } } return false; @@ -5107,9 +5113,7 @@ return y === Number.POSITIVE_INFINITY; } - x = LNumber(x); - y = LNumber(y); - return x.__type__ === y.__type__ && x.cmp(y) === 0; + return equal(LNumber(x), LNumber(y)); } else if (x instanceof LCharacter) { if (!(y instanceof LCharacter)) { return false; @@ -7483,11 +7487,11 @@ rational: i, complex: function complex(a, b) { return [{ - im: coerce(a.__type__, b.__im__.__type__, 0), - re: coerce(a.__type__, b.__re__.__type__, a) + im: coerce(a.__type__, b.__im__.__type__, 0)[0], + re: coerce(a.__type__, b.__re__.__type__, a)[0] }, { - im: coerce(a.__type__, b.__im__.__type__, b.__im__), - re: coerce(a.__type__, b.__re__.__type__, b.__re__) + im: coerce(a.__type__, b.__im__.__type__, b.__im__)[0], + re: coerce(a.__type__, b.__re__.__type__, b.__re__)[0] }]; } } @@ -7496,19 +7500,19 @@ function complex(type) { return function (a, b) { return [{ - im: coerce(type, a.__im__.__type__, a.__im__), - re: coerce(type, a.__re__.__type__, a.__re__) + im: coerce(type, a.__im__.__type__, 0, a.__im__)[1], + re: coerce(type, a.__re__.__type__, 0, a.__re__)[1] }, { - im: coerce(type, a.__im__.__type__, 0), - re: coerce(type, b.__type__, b) + im: coerce(type, a.__im__.__type__, 0, 0)[1], + re: coerce(type, b.__type__, 0, b)[1] }]; }; } }(); // ------------------------------------------------------------------------- - function coerce(type_a, type_b, a) { - return matrix[type_a][type_b](a)[0]; + function coerce(type_a, type_b, a, b) { + return matrix[type_a][type_b](a, b); } // ------------------------------------------------------------------------- @@ -7530,7 +7534,8 @@ throw new Error("LNumber::coerce unknown rhs type ".concat(b_type)); } - return matrix[a_type][b_type](a, b).map(function (n) { + var tmp = matrix[a_type][b_type](a, b); + return tmp.map(function (n) { return LNumber(n, true); }); }; // ------------------------------------------------------------------------- @@ -7907,7 +7912,7 @@ re: b.__re__, im: b.__im__.sub() }); - var denom = b.factor().valueOf(); + var denom = b.factor(); var num = a.mul(conj); var re = num.__re__.op('/', denom); @@ -8049,6 +8054,12 @@ } if (typeof n === 'number') { + if (Object.is(n, -0)) { + Object.defineProperty(this, '_minus', { + value: true + }); + } + this.constant(n, 'float'); } } // ------------------------------------------------------------------------- @@ -8061,7 +8072,8 @@ var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { - return str + '.0'; + var result = str + '.0'; + return this._minus ? '-' + result : result; } return str.replace(/^([0-9]+)e/, '$1.0e'); @@ -13197,10 +13209,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 24 Feb 2021 16:22:48 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 25 Feb 2021 11:23:00 +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('Wed, 24 Feb 2021 16:22:48 +0000').valueOf(); + var date = LString('Thu, 25 Feb 2021 11:23:00 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13240,7 +13252,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 24 Feb 2021 16:22:48 +0000', + date: 'Thu, 25 Feb 2021 11:23:00 +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 6b1fad66..a0776e4e 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 24 Feb 2021 16:22:48 +0000 + * build: Thu, 25 Feb 2021 11:23:00 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}return n&&e.cmp(r)===0}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}e=LNumber(e);r=LNumber(r);return e.__type__===r.__type__&&e.cmp(r)===0}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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0),re:coerce(r.__type__,n.__re__.__type__,r)},{im:coerce(r.__type__,n.__im__.__type__,n.__im__),re:coerce(r.__type__,n.__re__.__type__,n.__re__)}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,e.__im__),re:coerce(n,e.__re__.__type__,e.__re__)},{im:coerce(n,e.__im__.__type__,0),re:coerce(n,r.__type__,r)}]}}}();function coerce(e,r,n){return matrix[e][r](n)[0]}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}return matrix[t][i](e,r).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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor().valueOf();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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"){this.constant(e,"float")}}LFloat.prototype=Object.create(LNumber.prototype);LFloat.prototype.constructor=LFloat;LFloat.prototype.toString=function(){var e=this.__value__.toString();if(!LNumber.isFloat(this.__value__)&&!e.match(/e/i)){return e+".0"}return e.replace(/^([0-9]+)e/,"$1.0e")};LFloat.prototype._op=function(e,r){if(r instanceof LNumber){r=r.__value__}var n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Wed, 24 Feb 2021 16:22:48 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Wed, 24 Feb 2021 16:22:48 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 11:23:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 11:23:00 +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,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/dist/std.min.scm b/dist/std.min.scm index a7692380..6fc26769 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -283,7 +283,7 @@ automatically quoted. So you can use expressions inside them. Only other literals, like other vectors or object.")(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")"))))(define (eqv? a b) "(eqv? a b) Function compare the values. It return true if they are the same, they -need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (= a b)) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) +need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (if (and (zero? a) (zero? b)) (eq? a._minus b._minus) (= a b))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) Function check if values are equal if both are pair or array it compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b))))(define make-promise (lambda (proc) "(make-promise fn) diff --git a/dist/std.scm b/dist/std.scm index f543d7dc..53f545f6 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1312,7 +1312,13 @@ Function compare the values. It return true if they are the same, they need to have same type" (if (string=? (type a) (type b)) - (cond ((number? a) (= a b)) + (cond ((number? a) + (or (and (exact? a) (exact? b) (= a b)) + (and (inexact? a) + (inexact? b) + (if (and (zero? a) (zero? b)) + (eq? a._minus b._minus) + (= a b))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) false)) diff --git a/examples/scheme-detect.scm b/examples/scheme-detect.scm index 44ee8ab6..4be03194 100755 --- a/examples/scheme-detect.scm +++ b/examples/scheme-detect.scm @@ -64,7 +64,7 @@ (ikarus (#f #f #f #t #f #t #f #t #f #f #f #f #t #f #f #t #t #t #f #f)) (scheme48 (#f #f #f #t #t #t #f #t #t #t #t #t #t #t #t #t #t #f #f #f)) (mit-scheme (#t #t #t #t #t #f #t #t #t #f #t #f #f #f #f #t #t #f #t #f)) - (lips (#t #f #f #t #f #t #f #t #t #f #f #f #t #t #t #t #t #t #t #f)) + (lips (#t #f #f #t #f #t #f #t #t #f #f #f #t #t #f #f #f #t #t #f)) (gauche (#f #f #f #t #f #f #f #t #t #f #f #f #f #f #f #t #t #f #f #f)))) ;; DETECT:MATCH-SIGNATURE @@ -73,15 +73,17 @@ ;; against a table of known signatures. (define (detect:match-signature) (let ((signature (detect:signature))) - ; Loop over the DETECT:KNOWN-SIGNATURES list + ;; Loop over the DETECT:KNOWN-SIGNATURES list (let test ((siglist detect:known-signatures)) (if (equal? '() siglist) - ; Return 'UNKNOWN if we're stumped - 'unknown - (let ((testsig (car siglist))) - (if (equal? (cadr testsig) signature) - (car testsig) - (test (cdr siglist)))))))) + ;; Return 'UNKNOWN if we're stumped + (begin + (print signature) + 'unknown) + (let ((testsig (car siglist))) + (if (equal? (cadr testsig) signature) + (car testsig) + (test (cdr siglist)))))))) ;; DETECT:NAME ;; Memoized form of DETECT:MATCH-SIGNATURE diff --git a/lib/R5RS.scm b/lib/R5RS.scm index c03c8156..80fe83e2 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -85,7 +85,13 @@ Function compare the values. It return true if they are the same, they need to have same type" (if (string=? (type a) (type b)) - (cond ((number? a) (= a b)) + (cond ((number? a) + (or (and (exact? a) (exact? b) (= a b)) + (and (inexact? a) + (inexact? b) + (if (and (zero? a) (zero? b)) + (eq? a._minus b._minus) + (= a b))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) false)) diff --git a/src/lips.js b/src/lips.js index a9c97bc4..1017d0b5 100644 --- a/src/lips.js +++ b/src/lips.js @@ -2855,7 +2855,12 @@ } else { type = true; } - return type && x.cmp(y) === 0; + if (type && x.cmp(y) === 0) { + if (x.valueOf() === 0) { + return Object.is(x.valueOf(), y.valueOf()); + } + return true; + } } return false; } else if (typeof x === 'number') { @@ -2871,9 +2876,7 @@ if (x === Number.POSITIVE_INFINITY) { return y === Number.POSITIVE_INFINITY; } - x = LNumber(x); - y = LNumber(y); - return x.__type__ === y.__type__ && x.cmp(y) === 0; + return equal(LNumber(x), LNumber(y)); } else if (x instanceof LCharacter) { if (!(y instanceof LCharacter)) { return false; @@ -4614,12 +4617,12 @@ complex: (a, b) => { return [ { - im: coerce(a.__type__, b.__im__.__type__, 0), - re: coerce(a.__type__, b.__re__.__type__, a) + im: coerce(a.__type__, b.__im__.__type__, 0)[0], + re: coerce(a.__type__, b.__re__.__type__, a)[0] }, { - im: coerce(a.__type__, b.__im__.__type__, b.__im__), - re: coerce(a.__type__, b.__re__.__type__, b.__re__) + im: coerce(a.__type__, b.__im__.__type__, b.__im__)[0], + re: coerce(a.__type__, b.__re__.__type__, b.__re__)[0] } ]; } @@ -4629,20 +4632,20 @@ return (a, b) => { return [ { - im: coerce(type, a.__im__.__type__, a.__im__), - re: coerce(type, a.__re__.__type__, a.__re__) + im: coerce(type, a.__im__.__type__, 0, a.__im__)[1], + re: coerce(type, a.__re__.__type__, 0, a.__re__)[1] }, { - im: coerce(type, a.__im__.__type__, 0), - re: coerce(type, b.__type__, b) + im: coerce(type, a.__im__.__type__, 0, 0)[1], + re: coerce(type, b.__type__, 0, b)[1] } ]; }; } })(); // ------------------------------------------------------------------------- - function coerce(type_a, type_b, a) { - return matrix[type_a][type_b](a)[0]; + function coerce(type_a, type_b, a, b) { + return matrix[type_a][type_b](a, b); } // ------------------------------------------------------------------------- LNumber.coerce = function(a, b) { @@ -4659,7 +4662,8 @@ } else if (!matrix[a_type][b_type]) { throw new Error(`LNumber::coerce unknown rhs type ${b_type}`); } - return matrix[a_type][b_type](a, b).map(n => LNumber(n, true)); + var tmp = matrix[a_type][b_type](a, b); + return tmp.map(n => LNumber(n, true)); }; // ------------------------------------------------------------------------- LNumber.prototype.coerce = function(n) { @@ -4951,7 +4955,7 @@ } const [ a, b ] = this.coerce(n); const conj = LComplex({ re: b.__re__, im: b.__im__.sub() }); - const denom = b.factor().valueOf(); + const denom = b.factor(); const num = a.mul(conj); const re = num.__re__.op('/', denom); const im = num.__im__.op('/', denom); @@ -5052,6 +5056,11 @@ return LFloat(n.valueOf()); } if (typeof n === 'number') { + if (Object.is(n, -0)) { + Object.defineProperty(this, '_minus', { + value: true + }); + } this.constant(n, 'float'); } } @@ -5062,7 +5071,8 @@ LFloat.prototype.toString = function() { var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { - return str + '.0'; + var result = str + '.0'; + return this._minus ? ('-' + result) : result; } return str.replace(/^([0-9]+)e/, '$1.0e'); }; diff --git a/tests/numbers.scm b/tests/numbers.scm index 3d7f0695..1e516f3d 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -236,10 +236,13 @@ (test "numbers: complex" (lambda (t) (t.is 10+0i 10) - (t.is 10+0.0i 10) - (t.is 10.0+0.0i 10.0) + (t.is 10+0i 10) + (t.is 10.0+0i 10.0) + (t.is 10+0.0i 10+0.0i) + (t.is 10.0+0.0i 10.0+0.0i) (t.is 1/2+0i 1/2) - (t.is (sqrt -1) +1.0i) + (t.is 1/2+0.0i 1/2+0.0i) + (t.is (sqrt -1) +1i) (t.is (sqrt 0.5) 0.7071067811865476) (t.is (sqrt -0.5) +0.7071067811865476i) (t.is (number->string 10e+10i) "+100000000000i") @@ -386,17 +389,17 @@ (test "numbers: sqrt" (lambda (t) (for-each (lambda (x) - (t.is (sqrt (* x x)) x)) + (t.is (= (sqrt (* x x)) x) #t)) '(5 5+2i 1/5+1/2i 1/2 5.0 8/9)) (for-each (lambda (pair) (let ((x (car pair))) - (t.is (sqrt (* x x)) (cdr pair)))) + (t.is (= (sqrt (* x x)) (cdr pair)) #t))) '((2.0+1/2i . 2+0.5i))) (for-each (lambda (pair) (let ((x (car pair))) - (t.is (sqrt (* x x)) (cdr pair)))) + (t.is (= (sqrt (* x x)) (cdr pair)) #t))) '((2+1/2i . 2+0.5i) (2+0.5i . 2+0.5i) @@ -498,3 +501,28 @@ #;(t.is (nan? 5.0-nan.0i) #t) #;(t.is (nan? -nan.0-nan.0i) #t) (t.is (nan? 1+2i) #f))) + +(test "numbers: zeros" + (lambda (t) + (let ((a 0) (b 0) (c 0.0) (d 0.0)) + (t.is (eq? a b) #t) + (t.is (eq? c d) #t) + (t.is (eq? a c) #f) + (t.is (= a b) #t) + (t.is (= a c) #t)))) + +(test "numbers: negative zero" + (lambda (t) + (let ((a 0) (b -0)) + (t.is (eq? a b) #t) + (t.is (eqv? a b) #t) + (t.is (equal? a b) #t) + (t.is (= a b) #t) + (t.is (number->string b) "0")) + (let ((a 0.0) (b -0.0)) + (t.is (eq? a b) #f) + (t.is (eqv? a b) #f) + (t.is (equal? a b) #f) + (t.is (= a b) #t) + (t.is (number->string b) "-0.0")))) + From 9660cb9214a62d2bdaf354dfbaf0c351e27f8626 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 25 Feb 2021 12:33:17 +0100 Subject: [PATCH 043/109] fix `exact->inexact` on complex numbers #34 --- CHANGELOG.md | 1 + dist/std.min.scm | 2 +- dist/std.scm | 4 ++-- lib/R5RS.scm | 4 ++-- tests/numbers.scm | 14 ++++++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8a72cfd..287c1d72 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * fix parsing complex with 0 inexact imaginary part * fix option -t --trace in Node REPL * fix `eqv?` on exact and inexact numbers according to R7RS spec +* fix `exact->inexact` on complex numbers ## 1.0.0-beta.11 ### Breaking diff --git a/dist/std.min.scm b/dist/std.min.scm index 6fc26769..45c4d93b 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -328,7 +328,7 @@ Return minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) ar Create complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t)))))(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__)))))(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n)))(define (exact->inexact n) "(exact->inexact n) -Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (. n (quote im)) :re (. n (quote re)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) +Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (exact->inexact (. n (quote __im__))) :re (exact->inexact (. n (quote __re__))))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n))(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan"))(define _this_env (current-environment))(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n) diff --git a/dist/std.scm b/dist/std.scm index 53f545f6..272f8c57 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1616,8 +1616,8 @@ Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) - ;; make-object (&) will use valueOf so it will be float even if it was rational - (lips.LComplex (object :im (. n 'im) :re (. n 're))) + (lips.LComplex (object :im (exact->inexact (. n '__im__)) + :re (exact->inexact (. n '__re__)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) true) n))) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 80fe83e2..cf1eb87e 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -389,8 +389,8 @@ Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) - ;; make-object (&) will use valueOf so it will be float even if it was rational - (lips.LComplex (object :im (. n 'im) :re (. n 're))) + (lips.LComplex (object :im (exact->inexact (. n '__im__)) + :re (exact->inexact (. n '__re__)))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) true) n))) diff --git a/tests/numbers.scm b/tests/numbers.scm index 1e516f3d..977c2144 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -526,3 +526,17 @@ (t.is (= a b) #t) (t.is (number->string b) "-0.0")))) +(test "numbers: exact->inexact" + (lambda (t) + (t.is (exact->inexact 10) 10.0) + (t.is (exact->inexact 1/2) 0.5) + (t.is (exact->inexact 0.5) 0.5) + (t.is (exact->inexact 10+10i) 10.0+10.0i) + (t.is (exact->inexact 1/2+1/2i) 0.5+0.5i) + (t.is (exact->inexact 10.0+10.0i) 10.0+10.0i) + + (t.is (exact->inexact 10+1/2i) 10.0+0.5i) + (t.is (exact->inexact 10.0+1/2i) 10.0+0.5i) + + (t.is (exact->inexact 1/2+10i) 0.5+10.0i) + (t.is (exact->inexact 1/2+10.0i) 0.5+10.0i))) From d792b7412a3799ecb3ee6aba0b55fd1f00c87baa Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 25 Feb 2021 12:38:20 +0100 Subject: [PATCH 044/109] +nan.0 and -nan.0 return by parser #34 --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 10 ++++++---- dist/lips.min.js | 4 ++-- dist/std.min.scm | 2 +- dist/std.scm | 4 ---- lib/R7RS.scm | 4 ---- src/lips.js | 2 ++ 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 287c1d72..caa4f855 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * automatic bootstrapping of `fs` with BrowserFS if exists * `pprint` in both REPLs now print in color [#33](https://github.com/jcubic/lips/issues/33) * add `nan?`, `infinite?` and `finite?` functions +* add `+nan.0` and `-nan.0` (R7RS) * properly handle negative inexact zero ### Bugfix * fix prism highlighting of names (for new context help) diff --git a/README.md b/README.md index 630c219e..12f7cbb7 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&951f1cd48fca27eea19082b8897fe6543f382903)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7edfa491b886ec9837f1c5b09220eccf)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&9660cb9214a62d2bdaf354dfbaf0c351e27f8626)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0c69087c1ab4f325d7c16901dde22af6)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 72c899e0..2fdc9605 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 11:23:00 +0000 + * build: Thu, 25 Feb 2021 11:37:18 +0000 */ (function () { 'use strict'; @@ -1859,6 +1859,8 @@ return parse_float(arg); } else if (arg === 'nil') { return nil; + } else if (['+nan.0', '-nan.0'].includes(arg)) { + return NaN; } else if (['true', '#t', '#true'].includes(arg)) { return true; } else if (['false', '#f', '#false'].includes(arg)) { @@ -13209,10 +13211,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 25 Feb 2021 11:23:00 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 25 Feb 2021 11:37:18 +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('Thu, 25 Feb 2021 11:23:00 +0000').valueOf(); + var date = LString('Thu, 25 Feb 2021 11:37:18 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13252,7 +13254,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 25 Feb 2021 11:23:00 +0000', + date: 'Thu, 25 Feb 2021 11:37:18 +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 a0776e4e..07897090 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 11:23:00 +0000 + * build: Thu, 25 Feb 2021 11:37:18 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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(["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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 11:23:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 11:23:00 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 11:37:18 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 11:37:18 +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,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/dist/std.min.scm b/dist/std.min.scm index 45c4d93b..8a8b72e1 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -713,7 +713,7 @@ Macro for defining records. Example of usage: ;; 1 (set-kdr! p 3) (print (kdr p)) -;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields))))))(define +nan.0 NaN)(define -nan.0 NaN)(define (nan? x) "(nan? x) +;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields))))))(define (nan? x) "(nan? x) Function check if argument x is Not a Number (NaN) value." (or (eq? x NaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x))))))(define (infinite? x) "(infinite? x) diff --git a/dist/std.scm b/dist/std.scm index 272f8c57..ae293231 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3534,10 +3534,6 @@ (set-obj! ,obj-name ',prop-name ,value-name))))))) fields)))) -;; ----------------------------------------------------------------------------- -(define +nan.0 NaN) -(define -nan.0 NaN) - ;; ----------------------------------------------------------------------------- (define (nan? x) "(nan? x) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index dd5e1614..a2ee02d4 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -772,10 +772,6 @@ (set-obj! ,obj-name ',prop-name ,value-name))))))) fields)))) -;; ----------------------------------------------------------------------------- -(define +nan.0 NaN) -(define -nan.0 NaN) - ;; ----------------------------------------------------------------------------- (define (nan? x) "(nan? x) diff --git a/src/lips.js b/src/lips.js index 1017d0b5..77018f92 100644 --- a/src/lips.js +++ b/src/lips.js @@ -545,6 +545,8 @@ return parse_float(arg); } else if (arg === 'nil') { return nil; + } else if (['+nan.0', '-nan.0'].includes(arg)) { + return NaN; } else if (['true', '#t', '#true'].includes(arg)) { return true; } else if (['false', '#f', '#false'].includes(arg)) { From a691a1a1c50535b2f0d4d5385de154d4e01c39e7 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Thu, 25 Feb 2021 16:04:51 +0100 Subject: [PATCH 045/109] base complex nan.0 and inf.0 #34 --- README.md | 4 +- dist/lips.js | 301 ++++++++++++++++++++++++++-------------------- dist/lips.min.js | 4 +- src/lips.js | 111 +++++++++++------ tests/numbers.scm | 36 ++++++ 5 files changed, 283 insertions(+), 173 deletions(-) diff --git a/README.md b/README.md index 12f7cbb7..355ab209 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&9660cb9214a62d2bdaf354dfbaf0c351e27f8626)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0c69087c1ab4f325d7c16901dde22af6)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&8aba082340d50361d5fe675fee8f5395ae423d14)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&47fc01151e21aea38890c12254cc8a3c)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 2fdc9605..171b4ddf 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 11:37:18 +0000 + * build: Thu, 25 Feb 2021 15:22:55 +0000 */ (function () { 'use strict'; @@ -1420,7 +1420,7 @@ function gen_complex_re(mnemonic, range) { // [+-]i have (?=..) so it don't match +i from +inf.0 - return "".concat(num_mnemicic_re(mnemonic), "(?:[+-]?(?:").concat(range, "+/").concat(range, "+|").concat(range, "+))?(?:[+-]i|[+-]?(?:").concat(range, "+/").concat(range, "+|").concat(range, "+)i)(?=[()[\\]\\s]|$)"); + return "".concat(num_mnemicic_re(mnemonic), "(?:[+-]?(?:").concat(range, "+/").concat(range, "+|nan.0|inf.0|").concat(range, "+))?(?:[+-]i|[+-]?(?:").concat(range, "+/").concat(range, "+|").concat(range, "+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)"); } function gen_integer_re(mnemonic, range) { @@ -1430,7 +1430,7 @@ var re_re = /^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/; var float_stre = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)'; // TODO: extend to ([+-]1/2|float)([+-]1/2|float) - var complex_float_stre = "(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|".concat(float_stre, "|[+-]?[0-9]+))?(?:").concat(float_stre, "|[+-](?:[0-9]+/[0-9]+|[0-9]+))i"); + 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(mnemonic, range) { @@ -1442,7 +1442,7 @@ fl = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))'; } - return new RegExp("^((?:(?:".concat(fl, "|[+-]?").concat(range, "+/").concat(range, "+(?!").concat(range, ")|[+-]?").concat(range, "+)").concat(neg, ")?)(").concat(fl, "|[+-]?").concat(range, "+/").concat(range, "+|[+-]?").concat(range, "+|[+-])i$"), 'i'); + return new RegExp("^((?:(?:".concat(fl, "|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(range, "+/").concat(range, "+(?!").concat(range, ")|[+-]?").concat(range, "+)").concat(neg, ")?)(").concat(fl, "|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(range, "+/").concat(range, "+|[+-]?").concat(range, "+|[+-])i$"), 'i'); } var complex_list_re = function () { @@ -1682,6 +1682,14 @@ } return _float; + } else if (n.match(/nan.0$/)) { + return LNumber(NaN); + } else if (n.match(/inf.0$/)) { + if (n[0] === '-') { + return LNumber(Number.NEGATIVE_INFINITY); + } + + return LNumber(Number.POSITIVE_INFINITY); } else { throw new Error('Internal Parser Error'); } @@ -4607,52 +4615,82 @@ return '#'; } } // ---------------------------------------------------------------------- + // instances extracted to make cyclomatic complexity of toString smaller - function toString(obj, quote, skip_cycles) { - if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { - return '#'; + var instances = new Map(); // ---------------------------------------------------------------------- + + [[Error, function (e) { + return e.message; + }], [Pair, function (pair, _ref12) { + var quote = _ref12.quote, + skip_cycles = _ref12.skip_cycles, + pair_args = _ref12.pair_args; + + // make sure that repr directly after update set the cycle ref + if (!skip_cycles) { + pair.markCycles(); } - if (str_mapping.has(obj)) { - return str_mapping.get(obj); + return pair.toString.apply(pair, [quote].concat(toConsumableArray(pair_args))); + }], [LCharacter, function (chr, _ref13) { + var quote = _ref13.quote; + + if (quote) { + return chr.toString(); } - if (obj instanceof Error) { - return obj.message; + return chr.valueOf(); + }], [LString, function (str, _ref14) { + var quote = _ref14.quote; + str = str.toString(); + + if (quote) { + return JSON.stringify(str).replace(/\\n/g, '\n'); } - if (obj instanceof Pair) { - var _obj; + return str; + }], [RegExp, function (re) { + return '#' + re.toString(); + }]].forEach(function (_ref15) { + var _ref16 = slicedToArray(_ref15, 2), + cls = _ref16[0], + fn = _ref16[1]; + + instances.set(cls, fn); + }); // ---------------------------------------------------------------------- - // make sure that repr directly after update set the cycle ref - if (!skip_cycles) { - obj.markCycles(); - } + function toString(obj, quote, skip_cycles) { + if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { + return '#'; + } - for (var _len4 = arguments.length, pair_args = new Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) { - pair_args[_key4 - 3] = arguments[_key4]; - } + var m_obj = obj instanceof LNumber ? obj.valueOf() : obj; - return (_obj = obj).toString.apply(_obj, [quote].concat(pair_args)); + if (str_mapping.has(m_obj)) { + return str_mapping.get(m_obj); } - if (Number.isNaN(obj)) { + if (Number.isNaN(m_obj)) { return '+nan.0'; } - if (obj instanceof LCharacter) { - if (quote) { - return obj.toString(); - } + if (obj) { + var cls = obj.constructor; - return obj.valueOf(); - } // constants + if (instances.has(cls)) { + for (var _len4 = arguments.length, pair_args = new Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) { + pair_args[_key4 - 3] = arguments[_key4]; + } + return instances.get(cls)(obj, { + quote: quote, + skip_cycles: skip_cycles, + pair_args: pair_args + }); + } + } // standard objects that have toString - if ([nil, eof].includes(obj)) { - return obj.toString(); - } var types = [LSymbol, LNumber, Macro, Values, InputPort, Environment]; @@ -4662,26 +4700,17 @@ if (obj instanceof _type2) { return obj.toString(quote); } - } + } // constants - if (obj instanceof RegExp) { - return '#' + obj.toString(); + + if ([nil, eof].includes(obj)) { + return obj.toString(); } if (is_function(obj)) { return function_to_string(obj); } - if (obj instanceof LString) { - obj = obj.toString(); - - if (quote) { - return JSON.stringify(obj).replace(/\\n/g, '\n'); - } - - return obj; - } - if (obj === root) { return '#'; } @@ -4939,9 +4968,9 @@ Pair.prototype.toString = function (quote) { - var _ref12 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - _ref12$nested = _ref12.nested, - nested = _ref12$nested === void 0 ? false : _ref12$nested; + var _ref17 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + _ref17$nested = _ref17.nested, + nested = _ref17$nested === void 0 ? false : _ref17$nested; if (is_debug()) { var result = []; @@ -5201,10 +5230,10 @@ }; // ---------------------------------------------------------------------- - Macro.prototype.invoke = function (code, _ref13, macro_expand) { - var env = _ref13.env, - dynamic_scope = _ref13.dynamic_scope, - error = _ref13.error; + Macro.prototype.invoke = function (code, _ref18, macro_expand) { + var env = _ref18.env, + dynamic_scope = _ref18.dynamic_scope, + error = _ref18.error; var args = { dynamic_scope: dynamic_scope, error: error, @@ -5228,7 +5257,7 @@ function macro_expand(single) { return /*#__PURE__*/function () { - var _ref14 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(code, args) { + var _ref19 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(code, args) { var env, traverse, _traverse; return regenerator.wrap(function _callee8$(_context8) { @@ -5433,7 +5462,7 @@ })); return function (_x4, _x5) { - return _ref14.apply(this, arguments); + return _ref19.apply(this, arguments); }; }(); } // ---------------------------------------------------------------------- @@ -5452,9 +5481,9 @@ Syntax.prototype = Object.create(Macro.prototype); - Syntax.prototype.invoke = function (code, _ref15, macro_expand) { - var error = _ref15.error, - env = _ref15.env; + Syntax.prototype.invoke = function (code, _ref20, macro_expand) { + var error = _ref20.error, + env = _ref20.env; var args = { error: error, env: env, @@ -6071,8 +6100,8 @@ function traverse(expr) { - var _ref16 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - disabled = _ref16.disabled; + var _ref21 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + disabled = _ref21.disabled; log('traverse>> ' + expr.toString()); @@ -6705,9 +6734,9 @@ } }).then(exec); } else { - values.forEach(function (_ref17) { - var name = _ref17.name, - value = _ref17.value; + values.forEach(function (_ref22) { + var name = _ref22.name, + value = _ref22.value; env.set(name, value); }); } @@ -6751,9 +6780,9 @@ function pararel(name, fn) { return new Macro(name, function (code) { - var _ref18 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref18.dynamic_scope, - error = _ref18.error; + var _ref23 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref23.dynamic_scope, + error = _ref23.error; var env = this; @@ -7173,7 +7202,9 @@ } } - if (typeof BigInt !== 'undefined') { + if (Number.isNaN(n)) { + this.constant(n, 'integer'); + } else if (typeof BigInt !== 'undefined') { if (typeof n !== 'bigint') { if (parsable) { var prefix; // default number base (radix) supported by BigInt constructor @@ -7309,12 +7340,12 @@ LNumber.isNumber = function (n) { - return n instanceof LNumber || !Number.isNaN(n) && LNumber.isNative(n) || LNumber.isBN(n); + return n instanceof LNumber || LNumber.isNative(n) || LNumber.isBN(n); }; // ------------------------------------------------------------------------- LNumber.isComplex = function (n) { - var ret = n instanceof LComplex || LNumber.isNumber(n.im) && LNumber.isNumber(n.re); + var ret = n instanceof LComplex || (LNumber.isNumber(n.im) || Number.isNaN(n.im)) && (LNumber.isNumber(n.re) || Number.isNaN(n.re)); return ret; }; // ------------------------------------------------------------------------- @@ -8028,13 +8059,23 @@ var result; if (this.__re__.cmp(0) !== 0) { - result = [this.__re__.toString()]; + result = [toString(this.__re__)]; } else { result = []; + } // NaN and inf already have sign + + + var im = this.__im__.valueOf(); + + var inf = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY].includes(im); + var im_str = toString(this.__im__); + + if (!inf && !Number.isNaN(im)) { + result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); + im_str = im_str.replace(/^-/, ''); } - result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); - result.push(this.__im__.toString().replace(/^-/, '')); + result.push(im_str); result.push('i'); return result.join(''); }; // ------------------------------------------------------------------------- @@ -8656,7 +8697,7 @@ InputPort.prototype._with_init_parser = function (make_parser, fn) { var self = this; return /*#__PURE__*/function () { - var _ref20 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { + var _ref25 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { var parser, _len15, args, @@ -8688,7 +8729,7 @@ })); return function () { - return _ref20.apply(this, arguments); + return _ref25.apply(this, arguments); }; }(); }; @@ -8909,11 +8950,11 @@ function Interpreter(name) { - var _ref21 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - stderr = _ref21.stderr, - stdin = _ref21.stdin, - stdout = _ref21.stdout, - obj = objectWithoutProperties(_ref21, ["stderr", "stdin", "stdout"]); + var _ref26 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + stderr = _ref26.stderr, + stdin = _ref26.stdin, + stdout = _ref26.stdout, + obj = objectWithoutProperties(_ref26, ["stderr", "stdin", "stdout"]); if (typeof this !== 'undefined' && !(this instanceof Interpreter) || typeof this === 'undefined') { return new Interpreter(name, _objectSpread({ @@ -9700,9 +9741,9 @@ return unbind(a) === unbind(b); }, "(%same-functions a b)\n\n Helper function that check if two bound functions are the same"), // ------------------------------------------------------------------ - help: doc(new Macro('help', function (code, _ref22) { - var dynamic_scope = _ref22.dynamic_scope, - error = _ref22.error; + help: doc(new Macro('help', function (code, _ref27) { + var dynamic_scope = _ref27.dynamic_scope, + error = _ref27.error; var symbol; if (code.car instanceof LSymbol) { @@ -9766,9 +9807,9 @@ 'set!': doc(new Macro('set!', function (code) { var _this13 = this; - var _ref23 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref23.dynamic_scope, - error = _ref23.error; + var _ref28 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref28.dynamic_scope, + error = _ref28.error; if (dynamic_scope) { dynamic_scope = this; @@ -9967,14 +10008,14 @@ }, "(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', /*#__PURE__*/function () { - var _ref24 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(code, _ref25) { + var _ref29 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(code, _ref30) { var dynamic_scope, error, self, scope, vars, test, body, eval_args, node, item, _loop3; return regenerator.wrap(function _callee13$(_context13) { while (1) { switch (_context13.prev = _context13.next) { case 0: - dynamic_scope = _ref25.dynamic_scope, error = _ref25.error; + dynamic_scope = _ref30.dynamic_scope, error = _ref30.error; self = this; if (dynamic_scope) { @@ -10121,13 +10162,13 @@ })); return function (_x10, _x11) { - return _ref24.apply(this, arguments); + return _ref29.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 (code, _ref26) { - var dynamic_scope = _ref26.dynamic_scope, - error = _ref26.error; + 'if': doc(new Macro('if', function (code, _ref31) { + var dynamic_scope = _ref31.dynamic_scope, + error = _ref31.error; if (dynamic_scope) { dynamic_scope = this; @@ -10219,9 +10260,9 @@ }(); }), "(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 (code, _ref27) { - var dynamic_scope = _ref27.dynamic_scope, - error = _ref27.error; + 'ignore': new Macro('ignore', function (code, _ref32) { + var dynamic_scope = _ref32.dynamic_scope, + error = _ref32.error; var args = { env: this, error: error @@ -10365,9 +10406,9 @@ }, "(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."), // ------------------------------------------------------------------ lambda: new Macro('lambda', function (code) { - var _ref28 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref28.dynamic_scope, - error = _ref28.error; + var _ref33 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref33.dynamic_scope, + error = _ref33.error; var self = this; @@ -10481,9 +10522,9 @@ 'macroexpand': new Macro('macroexpand', macro_expand()), 'macroexpand-1': new Macro('macroexpand-1', macro_expand(true)), // ------------------------------------------------------------------ - 'define-macro': doc(new Macro(macro, function (macro, _ref29) { - var dynamic_scope = _ref29.dynamic_scope, - error = _ref29.error; + 'define-macro': doc(new Macro(macro, function (macro, _ref34) { + var dynamic_scope = _ref34.dynamic_scope, + error = _ref34.error; if (macro.car instanceof Pair && macro.car.car instanceof LSymbol) { var name = macro.car.car.__name__; @@ -10595,8 +10636,8 @@ validate_identifiers(macro.car); } - var syntax = new Syntax(function (code, _ref30) { - var macro_expand = _ref30.macro_expand; + var syntax = new Syntax(function (code, _ref35) { + var macro_expand = _ref35.macro_expand; var scope = env.inherit('syntax'); if (dynamic_scope) { @@ -10735,10 +10776,10 @@ } if (is_promise(car) || is_promise(cdr)) { - return Promise.all([car, cdr]).then(function (_ref31) { - var _ref32 = slicedToArray(_ref31, 2), - car = _ref32[0], - cdr = _ref32[1]; + return Promise.all([car, cdr]).then(function (_ref36) { + var _ref37 = slicedToArray(_ref36, 2), + car = _ref37[0], + cdr = _ref37[1]; return new Pair(car, cdr); }); @@ -11419,11 +11460,11 @@ return false; }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ - 'try': doc(new Macro('try', function (code, _ref33) { + 'try': doc(new Macro('try', function (code, _ref38) { var _this15 = this; - var dynamic_scope = _ref33.dynamic_scope, - _error = _ref33.error; + var dynamic_scope = _ref38.dynamic_scope, + _error = _ref38.error; return new Promise(function (resolve, reject) { var catch_clause, finally_clause; @@ -11906,9 +11947,9 @@ // ------------------------------------------------------------------ 'eq?': doc('eq?', equal, "(eq? a b)\n\n Function compare two values if they are identical."), // ------------------------------------------------------------------ - or: doc(new Macro('or', function (code, _ref34) { - var dynamic_scope = _ref34.dynamic_scope, - error = _ref34.error; + or: doc(new Macro('or', function (code, _ref39) { + var dynamic_scope = _ref39.dynamic_scope, + error = _ref39.error; var args = global_env.get('list->array')(code); var self = this; @@ -11951,9 +11992,9 @@ }), "(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 (code) { - var _ref35 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref35.dynamic_scope, - error = _ref35.error; + var _ref40 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref40.dynamic_scope, + error = _ref40.error; var args = global_env.get('list->array')(code); var self = this; @@ -12462,10 +12503,10 @@ } // ------------------------------------------------------------------------- - function evaluate_args(rest, _ref36) { - var env = _ref36.env, - dynamic_scope = _ref36.dynamic_scope, - error = _ref36.error; + function evaluate_args(rest, _ref41) { + var env = _ref41.env, + dynamic_scope = _ref41.dynamic_scope, + error = _ref41.error; var args = []; var node = rest; markCycles(node); @@ -12584,11 +12625,11 @@ function apply(fn, args) { - var _ref37 = arguments.length > 2 && arguments[2] !== undefined$1 ? arguments[2] : {}, - env = _ref37.env, - dynamic_scope = _ref37.dynamic_scope, - _ref37$error = _ref37.error, - error = _ref37$error === void 0 ? function () {} : _ref37$error; + var _ref42 = arguments.length > 2 && arguments[2] !== undefined$1 ? arguments[2] : {}, + env = _ref42.env, + dynamic_scope = _ref42.dynamic_scope, + _ref42$error = _ref42.error, + error = _ref42$error === void 0 ? function () {} : _ref42$error; args = evaluate_args(args, { env: env, @@ -12633,11 +12674,11 @@ function evaluate(code) { - var _ref38 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - env = _ref38.env, - dynamic_scope = _ref38.dynamic_scope, - _ref38$error = _ref38.error, - error = _ref38$error === void 0 ? function () {} : _ref38$error; + var _ref43 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + env = _ref43.env, + dynamic_scope = _ref43.dynamic_scope, + _ref43$error = _ref43.error, + error = _ref43$error === void 0 ? function () {} : _ref43$error; try { if (dynamic_scope === true) { @@ -13211,10 +13252,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 25 Feb 2021 11:37:18 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 25 Feb 2021 15:22:55 +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('Thu, 25 Feb 2021 11:37:18 +0000').valueOf(); + var date = LString('Thu, 25 Feb 2021 15:22:55 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13254,7 +13295,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 25 Feb 2021 11:37:18 +0000', + date: 'Thu, 25 Feb 2021 15:22:55 +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 07897090..81a67001 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 11:37:18 +0000 + * build: Thu, 25 Feb 2021 15:22:55 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(n);return m}}},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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};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,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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,"+|").concat(r,"+))?(?:[+-]i|[+-]?(?:").concat(r,"+/").concat(r,"+|").concat(r,"+)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]+|".concat(float_stre,"|[+-]?[0-9]+))?(?:").concat(float_stre,"|[+-](?:[0-9]+/[0-9]+|[0-9]+))i");var float_re=new RegExp("^(#[ie])?".concat(float_stre,"$"),"i");function make_complex_match_re(e,r){var n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[+-]?").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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#")}else{return"#"}}function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e instanceof Error){return e.message}if(e instanceof Pair){var t;if(!n){e.markCycles()}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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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(n);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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var d=_.slice(1);if(d.length){t(f,d)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var m=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(m,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var d=defineProperty({},h,n[h]);var m=n[h]===null;var v=nil;var y=function e(){if(!N(d,true)){k({bind:d});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,d,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}d=t};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}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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||!Number.isNaN(e)&&LNumber.isNative(e)||LNumber.isBN(e)};LNumber.isComplex=function(e){var r=e instanceof LComplex||LNumber.isNumber(e.im)&&LNumber.isNumber(e.re);return r};LNumber.isRational=function(e){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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=[this.__re__.toString()]}else{e=[]}e.push(this.__im__.cmp(0)<0?"-":"+");e.push(this.__im__.toString().replace(/^-/,""));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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&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 n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=d(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function d(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=d(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,d(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 11:37:18 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 11:37:18 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}var t=e instanceof LNumber?e.valueOf():e;if(str_mapping.has(t)){return str_mapping.get(t)}if(Number.isNaN(t)){return"+nan.0"}if(e){var i=e.constructor;if(instances.has(i)){for(var a=arguments.length,u=new Array(a>3?a-3:0),o=3;o"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var _=e.constructor;if(!_){_=Object}var p;if(typeof _.__class__==="string"){p=_.__class__}else{if(is_prototype(e)){return"#"}var h=user_repr(e);if(h){if(is_function(h)){return h(e,r)}else{throw new Error("toString: Invalid repr value")}}p=_.name}if(type(e)==="instance"&&!is_native_function(_)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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)){this.constant(e,"integer")}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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){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){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){e.push(this.__im__.cmp(0)<0?"-":"+");t=t.replace(/^-/,"")}e.push(t);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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 15:22:55 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 15:22:55 +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,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/src/lips.js b/src/lips.js index 77018f92..cb748e1b 100644 --- a/src/lips.js +++ b/src/lips.js @@ -187,7 +187,7 @@ // TODO: float complex function gen_complex_re(mnemonic, range) { // [+-]i have (?=..) so it don't match +i from +inf.0 - return `${num_mnemicic_re(mnemonic)}(?:[+-]?(?:${range}+/${range}+|${range}+))?(?:[+-]i|[+-]?(?:${range}+/${range}+|${range}+)i)(?=[()[\\]\\s]|$)`; + return `${num_mnemicic_re(mnemonic)}(?:[+-]?(?:${range}+/${range}+|nan.0|inf.0|${range}+))?(?:[+-]i|[+-]?(?:${range}+/${range}+|${range}+|nan.0|inf.0)i)(?=[()[\\]\\s]|$)`; } function gen_integer_re(mnemonic, range) { return `${num_mnemicic_re(mnemonic)}[+-]?${range}+`; @@ -195,7 +195,7 @@ var re_re = /^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimyus]*)$/; var float_stre = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)|[0-9]+\\.)'; // TODO: extend to ([+-]1/2|float)([+-]1/2|float) - var complex_float_stre = `(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|${float_stre}|[+-]?[0-9]+))?(?:${float_stre}|[+-](?:[0-9]+/[0-9]+|[0-9]+))i`; + var complex_float_stre = `(?:#[ie])?(?:[+-]?(?:[0-9]+/[0-9]+|nan.0|inf.0|${float_stre}|[+-]?[0-9]+))?(?:${float_stre}|[+-](?:[0-9]+/[0-9]+|[0-9]+|nan.0|inf.0))i`; var float_re = new RegExp(`^(#[ie])?${float_stre}$`, 'i'); function make_complex_match_re(mnemonic, range) { // complex need special treatment of 10e+1i when it's hex or decimal @@ -204,7 +204,7 @@ if (mnemonic === '') { fl = '(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))'; } - return new RegExp(`^((?:(?:${fl}|[+-]?${range}+/${range}+(?!${range})|[+-]?${range}+)${neg})?)(${fl}|[+-]?${range}+/${range}+|[+-]?${range}+|[+-])i$`, 'i'); + return new RegExp(`^((?:(?:${fl}|[-+]?inf.0|[-+]?nan.0|[+-]?${range}+/${range}+(?!${range})|[+-]?${range}+)${neg})?)(${fl}|[-+]?inf.0|[-+]?nan.0|[+-]?${range}+/${range}+|[+-]?${range}+|[+-])i$`, 'i'); } var complex_list_re = (function() { var result = {}; @@ -410,6 +410,13 @@ return float.toRational(); } return float; + } else if (n.match(/nan.0$/)) { + return LNumber(NaN); + } else if (n.match(/inf.0$/)) { + if (n[0] === '-') { + return LNumber(Number.NEGATIVE_INFINITY); + } + return LNumber(Number.POSITIVE_INFINITY); } else { throw new Error('Internal Parser Error'); } @@ -2484,56 +2491,72 @@ } } // ---------------------------------------------------------------------- + // instances extracted to make cyclomatic complexity of toString smaller + const instances = new Map(); + // ---------------------------------------------------------------------- + [ + [Error, function(e) { + return e.message; + }], + [Pair, function(pair, { quote, skip_cycles, pair_args }) { + // make sure that repr directly after update set the cycle ref + if (!skip_cycles) { + pair.markCycles(); + } + return pair.toString(quote, ...pair_args); + }], + [LCharacter, function(chr, { quote }) { + if (quote) { + return chr.toString(); + } + return chr.valueOf(); + }], + [LString, function(str, { quote }) { + str = str.toString(); + if (quote) { + return JSON.stringify(str).replace(/\\n/g, '\n'); + } + return str; + }], + [RegExp, function(re) { + return '#' + re.toString(); + }] + ].forEach(([cls, fn]) => { + instances.set(cls, fn); + }); + // ---------------------------------------------------------------------- function toString(obj, quote, skip_cycles, ...pair_args) { if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { return '#'; } - if (str_mapping.has(obj)) { - return str_mapping.get(obj); - } - if (obj instanceof Error) { - return obj.message; + var m_obj = obj instanceof LNumber ? obj.valueOf() : obj; + if (str_mapping.has(m_obj)) { + return str_mapping.get(m_obj); } - if (obj instanceof Pair) { - // make sure that repr directly after update set the cycle ref - if (!skip_cycles) { - obj.markCycles(); - } - return obj.toString(quote, ...pair_args); - } - if (Number.isNaN(obj)) { + if (Number.isNaN(m_obj)) { return '+nan.0'; } - if (obj instanceof LCharacter) { - if (quote) { - return obj.toString(); + if (obj) { + var cls = obj.constructor; + if (instances.has(cls)) { + return instances.get(cls)(obj, { quote, skip_cycles, pair_args }); } - return obj.valueOf(); - } - // constants - if ([nil, eof].includes(obj)) { - return obj.toString(); } + // standard objects that have toString var types = [LSymbol, LNumber, Macro, Values, InputPort, Environment]; for (let type of types) { if (obj instanceof type) { return obj.toString(quote); } } - if (obj instanceof RegExp) { - return '#' + obj.toString(); + // constants + if ([nil, eof].includes(obj)) { + return obj.toString(); } if (is_function(obj)) { return function_to_string(obj); } - if (obj instanceof LString) { - obj = obj.toString(); - if (quote) { - return JSON.stringify(obj).replace(/\\n/g, '\n'); - } - return obj; - } if (obj === root) { return '#'; } @@ -4390,7 +4413,9 @@ } } } - if (typeof BigInt !== 'undefined') { + if (Number.isNaN(n)) { + this.constant(n, 'integer'); + } else if (typeof BigInt !== 'undefined') { if (typeof n !== 'bigint') { if (parsable) { let prefix; @@ -4496,12 +4521,13 @@ // ------------------------------------------------------------------------- LNumber.isNumber = function(n) { return n instanceof LNumber || - (!Number.isNaN(n) && LNumber.isNative(n) || LNumber.isBN(n)); + (LNumber.isNative(n) || LNumber.isBN(n)); }; // ------------------------------------------------------------------------- LNumber.isComplex = function(n) { var ret = n instanceof LComplex || - (LNumber.isNumber(n.im) && LNumber.isNumber(n.re)); + ((LNumber.isNumber(n.im) || Number.isNaN(n.im)) && + (LNumber.isNumber(n.re) || Number.isNaN(n.re))); return ret; }; // ------------------------------------------------------------------------- @@ -5034,12 +5060,19 @@ LComplex.prototype.toString = function() { var result; if (this.__re__.cmp(0) !== 0) { - result = [this.__re__.toString()]; + result = [toString(this.__re__)]; } else { result = []; } - result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); - result.push(this.__im__.toString().replace(/^-/, '')); + // NaN and inf already have sign + var im = this.__im__.valueOf(); + var inf = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY].includes(im); + var im_str = toString(this.__im__); + if (!inf && !Number.isNaN(im)) { + result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); + im_str = im_str.replace(/^-/, ''); + } + result.push(im_str); result.push('i'); return result.join(''); }; diff --git a/tests/numbers.scm b/tests/numbers.scm index 977c2144..00dfa94e 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -18,6 +18,42 @@ (t.is (/ (make-rectangular 1 2) (make-rectangular 2 10)) (/ 1+2i 2+10i)))) +(test "numbers: complex NaN" + (lambda (t) + (t.is (number->string +nan.0+10i) "+nan.0+10i") + (t.is (number->string +nan.0+10.0i) "+nan.0+10.0i") + (t.is (number->string +nan.0+1/2i) "+nan.0+1/2i") + + (t.is (number->string 10+nan.0i) "10+nan.0i") + (t.is (number->string 10.0+nan.0i) "10.0+nan.0i") + (t.is (number->string 1/2+nan.0i) "1/2+nan.0i") + + (t.is (number->string -nan.0+10i) "+nan.0+10i") + (t.is (number->string -nan.0+10.0i) "+nan.0+10.0i") + (t.is (number->string -nan.0+1/2i) "+nan.0+1/2i") + + (t.is (number->string 10-nan.0i) "10+nan.0i") + (t.is (number->string 10.0-nan.0i) "10.0+nan.0i") + (t.is (number->string 1/2-nan.0i) "1/2+nan.0i"))) + +(test "numbers: complex infinity" + (lambda (t) + (t.is (number->string +inf.0+10i) "+inf.0+10i") + (t.is (number->string +inf.0+10.0i) "+inf.0+10.0i") + (t.is (number->string +inf.0+1/2i) "+inf.0+1/2i") + + (t.is (number->string 10+inf.0i) "10+inf.0i") + (t.is (number->string 10.0+inf.0i) "10.0+inf.0i") + (t.is (number->string 1/2+inf.0i) "1/2+inf.0i") + + (t.is (number->string -inf.0+10i) "-inf.0+10i") + (t.is (number->string -inf.0+10.0i) "-inf.0+10.0i") + (t.is (number->string -inf.0+1/2i) "-inf.0+1/2i") + + (t.is (number->string 10-inf.0i) "10-inf.0i") + (t.is (number->string 10.0-inf.0i) "10.0-inf.0i") + (t.is (number->string 1/2-inf.0i) "1/2-inf.0i"))) + (test "numbers: not numbers" (lambda (t) (t.is (. (lips.parse "0.1/0.1") 0) '0.1/0.1) From ca413bb4e54e04c754d7d74c7a92ad7376c4075d Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Fri, 26 Feb 2021 12:27:56 +0100 Subject: [PATCH 046/109] refactor nan.0 and inf.0 Refactor toString function Allow operation on nan.0 and complex nan.0 --- README.md | 2 +- dist/lips.js | 42 ++++++++++++++++++++++++++++-------------- dist/lips.min.js | 4 ++-- src/lips.js | 27 ++++++++++++++++++--------- 4 files changed, 49 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 355ab209..c42a04a0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&8aba082340d50361d5fe675fee8f5395ae423d14)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a691a1a1c50535b2f0d4d5385de154d4e01c39e7)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&47fc01151e21aea38890c12254cc8a3c)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 171b4ddf..140f8b14 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 15:22:55 +0000 + * build: Fri, 26 Feb 2021 11:27:00 +0000 */ (function () { 'use strict'; @@ -1868,7 +1868,7 @@ } else if (arg === 'nil') { return nil; } else if (['+nan.0', '-nan.0'].includes(arg)) { - return NaN; + return LNumber(NaN); } else if (['true', '#t', '#true'].includes(arg)) { return true; } else if (['false', '#f', '#false'].includes(arg)) { @@ -4522,7 +4522,7 @@ var str_mapping = new Map(); - [[Number.NEGATIVE_INFINITY, '-inf.0'], [Number.POSITIVE_INFINITY, '+inf.0'], [true, '#t'], [false, '#f'], [null, 'null'], [undefined$1, '#']].forEach(function (_ref10) { + [[true, '#t'], [false, '#f'], [null, 'null'], [undefined$1, '#']].forEach(function (_ref10) { var _ref11 = slicedToArray(_ref10, 2), key = _ref11[0], value = _ref11[1]; @@ -4665,14 +4665,8 @@ return '#'; } - var m_obj = obj instanceof LNumber ? obj.valueOf() : obj; - - if (str_mapping.has(m_obj)) { - return str_mapping.get(m_obj); - } - - if (Number.isNaN(m_obj)) { - return '+nan.0'; + if (str_mapping.has(obj)) { + return str_mapping.get(obj); } if (obj) { @@ -7405,6 +7399,10 @@ LNumber.prototype.toString = LNumber.prototype.toJSON = function (radix) { + if (Number.isNaN(this.__value__)) { + return '+nan.0'; + } + if (radix > 2 && radix < 36) { return this.__value__.toString(radix); } @@ -7682,6 +7680,14 @@ return LNumber(LNumber._ops[op](this.valueOf())); } + if (typeof n === 'number') { + n = LNumber(n); + } + + if (Number.isNaN(this.__value__) || Number.isNaN(n.__value__)) { + return LNumber(NaN); + } + var _this$coerce = this.coerce(n), _this$coerce2 = slicedToArray(_this$coerce, 2), a = _this$coerce2[0], @@ -8112,6 +8118,14 @@ 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'; + } + var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { @@ -13252,10 +13266,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 25 Feb 2021 15:22:55 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 26 Feb 2021 11:27:00 +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('Thu, 25 Feb 2021 15:22:55 +0000').valueOf(); + var date = LString('Fri, 26 Feb 2021 11:27:00 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13295,7 +13309,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 25 Feb 2021 15:22:55 +0000', + date: 'Fri, 26 Feb 2021 11:27:00 +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 81a67001..901faa53 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 25 Feb 2021 15:22:55 +0000 + * build: Fri, 26 Feb 2021 11:27:00 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[Number.NEGATIVE_INFINITY,"-inf.0"],[Number.POSITIVE_INFINITY,"+inf.0"],[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}var t=e instanceof LNumber?e.valueOf():e;if(str_mapping.has(t)){return str_mapping.get(t)}if(Number.isNaN(t)){return"+nan.0"}if(e){var i=e.constructor;if(instances.has(i)){for(var a=arguments.length,u=new Array(a>3?a-3:0),o=3;o"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var _=e.constructor;if(!_){_=Object}var p;if(typeof _.__class__==="string"){p=_.__class__}else{if(is_prototype(e)){return"#"}var h=user_repr(e);if(h){if(is_function(h)){return h(e,r)}else{throw new Error("toString: Invalid repr value")}}p=_.name}if(type(e)==="instance"&&!is_native_function(_)){p="instance"}if(is_iterator(e,Symbol.iterator)){if(p){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(p){return"#")}return"#"}if(p!==""){return"#<"+p+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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)){this.constant(e,"integer")}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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){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){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(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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){e.push(this.__im__.cmp(0)<0?"-":"+");t=t.replace(/^-/,"")}e.push(t);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(){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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Thu, 25 Feb 2021 15:22:55 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Thu, 25 Feb 2021 15:22:55 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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)){this.constant(e,"integer")}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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){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){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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){e.push(this.__im__.cmp(0)<0?"-":"+");t=t.replace(/^-/,"")}e.push(t);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"}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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 26 Feb 2021 11:27:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Fri, 26 Feb 2021 11:27:00 +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,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/src/lips.js b/src/lips.js index cb748e1b..e513e728 100644 --- a/src/lips.js +++ b/src/lips.js @@ -553,7 +553,7 @@ } else if (arg === 'nil') { return nil; } else if (['+nan.0', '-nan.0'].includes(arg)) { - return NaN; + return LNumber(NaN); } else if (['true', '#t', '#true'].includes(arg)) { return true; } else if (['false', '#f', '#false'].includes(arg)) { @@ -2413,8 +2413,6 @@ // ---------------------------------------------------------------------- var str_mapping = new Map(); [ - [Number.NEGATIVE_INFINITY, '-inf.0'], - [Number.POSITIVE_INFINITY, '+inf.0'], [true, '#t'], [false, '#f'], [null, 'null'], @@ -2530,12 +2528,8 @@ obj instanceof jQuery.fn.init) { return '#'; } - var m_obj = obj instanceof LNumber ? obj.valueOf() : obj; - if (str_mapping.has(m_obj)) { - return str_mapping.get(m_obj); - } - if (Number.isNaN(m_obj)) { - return '+nan.0'; + if (str_mapping.has(obj)) { + return str_mapping.get(obj); } if (obj) { var cls = obj.constructor; @@ -4576,6 +4570,9 @@ }; // ------------------------------------------------------------------------- LNumber.prototype.toString = LNumber.prototype.toJSON = function(radix) { + if (Number.isNaN(this.__value__)) { + return '+nan.0'; + } if (radix > 2 && radix < 36) { return this.__value__.toString(radix); } @@ -4790,6 +4787,12 @@ if (typeof n === 'undefined') { return LNumber(LNumber._ops[op](this.valueOf())); } + if (typeof n === 'number') { + n = LNumber(n); + } + if (Number.isNaN(this.__value__) || Number.isNaN(n.__value__)) { + return LNumber(NaN); + } const [a, b] = this.coerce(n); if (a._op) { return a._op(op, b); @@ -5104,6 +5107,12 @@ 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'; + } var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { var result = str + '.0'; From 3d203fd2b38559cabe2058e6e38df47e1ee4e598 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Fri, 26 Feb 2021 14:39:07 +0100 Subject: [PATCH 047/109] fixes and imrovements to NaN and -0.0 #34 --- Makefile | 4 +- README.md | 4 +- dist/lips.js | 92 ++++++++++++++++++++++++++++++++-------------- dist/lips.min.js | 4 +- dist/std.min.scm | 4 +- dist/std.scm | 34 +++++++++++++---- lib/R5RS.scm | 25 +++++++++++-- lib/R7RS.scm | 9 +++-- src/lips.js | 62 +++++++++++++++++++------------ templates/Makefile | 4 +- tests/numbers.scm | 75 +++++++++++++++++++++++++++++++++---- 11 files changed, 234 insertions(+), 83 deletions(-) diff --git a/Makefile b/Makefile index f0077b92..7a5db088 100644 --- a/Makefile +++ b/Makefile @@ -86,10 +86,10 @@ publish: jest-test: dist/lips.js @$(JEST) --coverage spec/*.spec.js -test: dist/lips.js dist/std.scm +test: dist/lips.js dist/std.min.scm @$(NPM) run test -test-file: dist/lips.js dist/std.scm +test-file: dist/lips.js dist/std.min.scm @$(NPM) run test -- -- -f $(FILE) test-update: dist/lips.js dist/std.scm diff --git a/README.md b/README.md index c42a04a0..616f3ca6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&a691a1a1c50535b2f0d4d5385de154d4e01c39e7)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&47fc01151e21aea38890c12254cc8a3c)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&ca413bb4e54e04c754d7d74c7a92ad7376c4075d)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&16b006fd82b5e9acd5fa1c8f60a3528d)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 140f8b14..09d1c5c7 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 26 Feb 2021 11:27:00 +0000 + * build: Fri, 26 Feb 2021 13:31:05 +0000 */ (function () { 'use strict'; @@ -1717,8 +1717,6 @@ if (parts[1]) { re = parse_num(parts[1]); - } else if (im instanceof LFloat) { - re = LFloat(0); } else { re = LNumber(0); } @@ -7197,7 +7195,7 @@ } if (Number.isNaN(n)) { - this.constant(n, 'integer'); + return LFloat(n); } else if (typeof BigInt !== 'undefined') { if (typeof n !== 'bigint') { if (parsable) { @@ -7301,6 +7299,11 @@ } }; // ------------------------------------------------------------------------- + LNumber.prototype.isNaN = function () { + return Number.isNaN(this.__value__); + }; // ------------------------------------------------------------------------- + + LNumber.prototype.gcd = function (b) { // ref: https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript var a = this.abs(); @@ -7440,6 +7443,8 @@ return this.__value__.toNumber(); } }; // ------------------------------------------------------------------------- + // type coercion matrix + // ------------------------------------------------------------------------- var matrix = function () { @@ -7449,17 +7454,35 @@ return { bigint: { - 'bigint': i, - 'float': function float(a, b) { + bigint: i, + "float": function float(a, b) { + return [LFloat(a.valueOf()), b]; + }, + rational: function rational(a, b) { + return [{ + num: a, + denom: 1 + }, b]; + }, + complex: function complex(a, b) { + return [{ + im: 0, + re: a + }, b]; + } + }, + integer: { + integer: i, + "float": function float(a, b) { return [LFloat(a.valueOf()), b]; }, - 'rational': function rational(a, b) { + rational: function rational(a, b) { return [{ num: a, denom: 1 }, b]; }, - 'complex': function complex(a, b) { + complex: function complex(a, b) { return [{ im: 0, re: a @@ -7467,14 +7490,17 @@ } }, "float": { - 'bigint': function bigint(a, b) { + bigint: function bigint(a, b) { + return [a, b && LFloat(b.valueOf())]; + }, + integer: function integer(a, b) { return [a, b && LFloat(b.valueOf())]; }, - 'float': i, - 'rational': function rational(a, b) { + "float": i, + rational: function rational(a, b) { return [a, b && LFloat(b.valueOf())]; }, - 'complex': function complex(a, b) { + complex: function complex(a, b) { return [{ re: a, im: LFloat(0) @@ -7483,6 +7509,7 @@ }, complex: { bigint: complex('bigint'), + integer: complex('integer'), "float": complex('float'), rational: complex('rational'), complex: function complex(a, b) { @@ -7512,6 +7539,12 @@ denom: 1 }]; }, + integer: function integer(a, b) { + return [a, b && { + num: b, + denom: 1 + }]; + }, "float": function float(a, b) { return [LFloat(a.valueOf()), b]; }, @@ -7548,16 +7581,8 @@ LNumber.coerce = function (a, b) { - function clean(type) { - if (type === 'integer') { - return 'bigint'; - } - - return type; - } - - var a_type = clean(LNumber.getType(a)); - var b_type = clean(LNumber.getType(b)); + var a_type = LNumber.getType(a); + var b_type = LNumber.getType(b); if (!matrix[a_type]) { throw new Error("LNumber::coerce unknown lhs type ".concat(a_type)); @@ -7684,7 +7709,7 @@ n = LNumber(n); } - if (Number.isNaN(this.__value__) || Number.isNaN(n.__value__)) { + if (Number.isNaN(this.__value__) && !LNumber.isComplex(n) || !LNumber.isComplex(this) && Number.isNaN(n.__value__)) { return LNumber(NaN); } @@ -8077,7 +8102,14 @@ var im_str = toString(this.__im__); if (!inf && !Number.isNaN(im)) { - result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); + var zero_check = this.__im__.cmp(0); + + if (zero_check < 0 || zero_check === 0 && this.__im__._minus) { + result.push('-'); + } else { + result.push('+'); + } + im_str = im_str.replace(/^-/, ''); } @@ -8126,6 +8158,10 @@ return '+inf.0'; } + if (Number.isNaN(this.__value__)) { + return '+nan.0'; + } + var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { @@ -9514,7 +9550,7 @@ 'true': true, 'false': false, 'null': null, - 'NaN': NaN, + 'NaN': LNumber(NaN), // ------------------------------------------------------------------ 'peek-char': doc('peek-char', function (port) { if (port) { @@ -13266,10 +13302,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 26 Feb 2021 11:27:00 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 26 Feb 2021 13:31:05 +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('Fri, 26 Feb 2021 11:27:00 +0000').valueOf(); + var date = LString('Fri, 26 Feb 2021 13:31:05 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13309,7 +13345,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 26 Feb 2021 11:27:00 +0000', + date: 'Fri, 26 Feb 2021 13:31:05 +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 901faa53..e6697b12 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 26 Feb 2021 11:27:00 +0000 + * build: Fri, 26 Feb 2021 13:31:05 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[1])}else if(o instanceof LFloat){u=LFloat(0)}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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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)){this.constant(e,"integer")}else if(typeof BigInt!=="undefined"){if(typeof e!=="bigint"){if(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};LNumber.prototype.gcd=function(e){var r=this.abs();e=e.abs();if(e.cmp(r)===1){var n=r;r=e;e=n}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){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){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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){function n(e){if(e==="integer"){return"bigint"}return e}var t=n(LNumber.getType(e));var i=n(LNumber.getType(r));if(!matrix[t]){throw new Error("LNumber::coerce unknown lhs type ".concat(t))}else if(!matrix[t][i]){throw new Error("LNumber::coerce unknown rhs type ".concat(i))}var a=matrix[t][i](e,r);return a.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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){e.push(this.__im__.cmp(0)<0?"-":"+");t=t.replace(/^-/,"")}e.push(t);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"}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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 26 Feb 2021 11:27:00 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Fri, 26 Feb 2021 11:27:00 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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){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){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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 26 Feb 2021 13:31:05 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Fri, 26 Feb 2021 13:31:05 +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,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/dist/std.min.scm b/dist/std.min.scm index 8a8b72e1..5acb90c7 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -283,7 +283,7 @@ automatically quoted. So you can use expressions inside them. Only other literals, like other vectors or object.")(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")"))))(define (eqv? a b) "(eqv? a b) Function compare the values. It return true if they are the same, they -need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (if (and (zero? a) (zero? b)) (eq? a._minus b._minus) (= a b))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) +need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (cond ((a.isNaN) (b.isNaN)) ((and (zero? a) (zero? b)) (eq? a._minus b._minus)) ((and (complex? a) (complex? b)) (let ((re.a (real-part a)) (re.b (real-part b)) (im.a (imag-part a)) (im.b (imag-part b))) (and (if (and (zero? re.a) (zero? re.b)) (eq? (. re.a (quote _minus)) (. re.b (quote _minus))) #t) (if (and (zero? im.a) (zero? im.b)) (eq? (. im.a (quote _minus)) (. im.b (quote _minus))) #t) (or (= re.a re.b) (and (--> re.a (isNaN)) (--> re.b (isNaN)))) (or (= im.a im.b) (and (--> im.a (isNaN)) (--> im.b (isNaN))))))) (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) Function check if values are equal if both are pair or array it compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b))))(define make-promise (lambda (proc) "(make-promise fn) @@ -715,7 +715,7 @@ Macro for defining records. Example of usage: (print (kdr p)) ;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields))))))(define (nan? x) "(nan? x) -Function check if argument x is Not a Number (NaN) value." (or (eq? x NaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x))))))(define (infinite? x) "(infinite? x) +Function check if argument x is Not a Number (NaN) value." (and (number? x) (or (x.isNaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x)))))))(define (infinite? x) "(infinite? x) Function check if value is infinite." (or (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (number? x) (not (eq? x NaN)) (%number-type "complex" x) (or (infinite? (real-part x)) (infinite? (imag-part x))))))(define (finite? x) "(finite? x) diff --git a/dist/std.scm b/dist/std.scm index ae293231..21ae260c 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1316,9 +1316,28 @@ (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) - (if (and (zero? a) (zero? b)) - (eq? a._minus b._minus) - (= a b))))) + (cond ((a.isNaN) (b.isNaN)) + ((and (zero? a) (zero? b)) + (eq? a._minus b._minus)) + ((and (complex? a) (complex? b)) + (let ((re.a (real-part a)) + (re.b (real-part b)) + (im.a (imag-part a)) + (im.b (imag-part b))) + (and + (if (and (zero? re.a) (zero? re.b)) + (eq? (. re.a '_minus) (. re.b '_minus)) + true) + (if (and (zero? im.a) (zero? im.b)) + (eq? (. im.a '_minus) (. im.b '_minus)) + true) + (or (= re.a re.b) + (and (--> re.a (isNaN)) + (--> re.b (isNaN)))) + (or (= im.a im.b) + (and (--> im.a (isNaN)) + (--> im.b (isNaN))))))) + (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) false)) @@ -3539,10 +3558,11 @@ "(nan? x) Function check if argument x is Not a Number (NaN) value." - (or (eq? x NaN) - (and (%number-type "complex" x) - (or (nan? (real-part x)) - (nan? (imag-part x)))))) + (and (number? x) + (or (x.isNaN) + (and (%number-type "complex" x) + (or (nan? (real-part x)) + (nan? (imag-part x))))))) ;; ----------------------------------------------------------------------------- (define (infinite? x) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index cf1eb87e..49e79635 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -89,9 +89,28 @@ (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) - (if (and (zero? a) (zero? b)) - (eq? a._minus b._minus) - (= a b))))) + (cond ((a.isNaN) (b.isNaN)) + ((and (zero? a) (zero? b)) + (eq? a._minus b._minus)) + ((and (complex? a) (complex? b)) + (let ((re.a (real-part a)) + (re.b (real-part b)) + (im.a (imag-part a)) + (im.b (imag-part b))) + (and + (if (and (zero? re.a) (zero? re.b)) + (eq? (. re.a '_minus) (. re.b '_minus)) + true) + (if (and (zero? im.a) (zero? im.b)) + (eq? (. im.a '_minus) (. im.b '_minus)) + true) + (or (= re.a re.b) + (and (--> re.a (isNaN)) + (--> re.b (isNaN)))) + (or (= im.a im.b) + (and (--> im.a (isNaN)) + (--> im.b (isNaN))))))) + (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) false)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index a2ee02d4..b938663c 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -777,10 +777,11 @@ "(nan? x) Function check if argument x is Not a Number (NaN) value." - (or (eq? x NaN) - (and (%number-type "complex" x) - (or (nan? (real-part x)) - (nan? (imag-part x)))))) + (and (number? x) + (or (x.isNaN) + (and (%number-type "complex" x) + (or (nan? (real-part x)) + (nan? (imag-part x))))))) ;; ----------------------------------------------------------------------------- (define (infinite? x) diff --git a/src/lips.js b/src/lips.js index e513e728..4b2ee7cf 100644 --- a/src/lips.js +++ b/src/lips.js @@ -438,8 +438,6 @@ im = parse_num(parts[2]); if (parts[1]) { re = parse_num(parts[1]); - } else if (im instanceof LFloat) { - re = LFloat(0, true); } else { re = LNumber(0); } @@ -4408,7 +4406,7 @@ } } if (Number.isNaN(n)) { - this.constant(n, 'integer'); + return LFloat(n); } else if (typeof BigInt !== 'undefined') { if (typeof n !== 'bigint') { if (parsable) { @@ -4488,6 +4486,10 @@ } }; // ------------------------------------------------------------------------- + LNumber.prototype.isNaN = function() { + return Number.isNaN(this.__value__); + }; + // ------------------------------------------------------------------------- LNumber.prototype.gcd = function(b) { // ref: https://rosettacode.org/wiki/Greatest_common_divisor#JavaScript var a = this.abs(); @@ -4607,23 +4609,33 @@ } }; // ------------------------------------------------------------------------- - var matrix = (function() { + // type coercion matrix + // ------------------------------------------------------------------------- + const matrix = (function() { var i = (a, b) => [a, b]; return { bigint: { - 'bigint': i, - 'float': (a, b) => [LFloat(a.valueOf(), true), b], - 'rational': (a, b) => [{ num: a, denom: 1 }, b], - 'complex': (a, b) => [{ im: 0, re: a }, b] + bigint: i, + float: (a, b) => [LFloat(a.valueOf(), true), b], + rational: (a, b) => [{ num: a, denom: 1 }, b], + complex: (a, b) => [{ im: 0, re: a }, b] + }, + integer: { + integer: i, + float: (a, b) => [LFloat(a.valueOf(), true), b], + rational: (a, b) => [{ num: a, denom: 1 }, b], + complex: (a, b) => [{ im: 0, re: a }, b] }, float: { - 'bigint': (a, b) => [a, b && LFloat(b.valueOf(), true)], - 'float': i, - 'rational': (a, b) => [a, b && LFloat(b.valueOf(), true)], - 'complex': (a, b) => [{ re: a, im: LFloat(0, true) }, b] + bigint: (a, b) => [a, b && LFloat(b.valueOf(), true)], + integer: (a, b) => [a, b && LFloat(b.valueOf(), true)], + float: i, + rational: (a, b) => [a, b && LFloat(b.valueOf(), true)], + complex: (a, b) => [{ re: a, im: LFloat(0, true) }, b] }, complex: { bigint: complex('bigint'), + integer: complex('integer'), float: complex('float'), rational: complex('rational'), complex: (a, b) => { @@ -4637,6 +4649,7 @@ }, rational: { bigint: (a, b) => [a, b && { num: b, denom: 1 }], + integer: (a, b) => [a, b && { num: b, denom: 1 }], float: (a, b) => [LFloat(a.valueOf()), b], rational: i, complex: (a, b) => { @@ -4674,14 +4687,8 @@ } // ------------------------------------------------------------------------- LNumber.coerce = function(a, b) { - function clean(type) { - if (type === 'integer') { - return 'bigint'; - } - return type; - } - const a_type = clean(LNumber.getType(a)); - const b_type = clean(LNumber.getType(b)); + const a_type = LNumber.getType(a); + const b_type = LNumber.getType(b); if (!matrix[a_type]) { throw new Error(`LNumber::coerce unknown lhs type ${a_type}`); } else if (!matrix[a_type][b_type]) { @@ -4790,7 +4797,8 @@ if (typeof n === 'number') { n = LNumber(n); } - if (Number.isNaN(this.__value__) || Number.isNaN(n.__value__)) { + if (Number.isNaN(this.__value__) && !LNumber.isComplex(n) || + !LNumber.isComplex(this) && Number.isNaN(n.__value__)) { return LNumber(NaN); } const [a, b] = this.coerce(n); @@ -5072,7 +5080,12 @@ var inf = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY].includes(im); var im_str = toString(this.__im__); if (!inf && !Number.isNaN(im)) { - result.push(this.__im__.cmp(0) < 0 ? '-' : '+'); + var zero_check = this.__im__.cmp(0); + if (zero_check < 0 || (zero_check === 0 && this.__im__._minus)) { + result.push('-'); + } else { + result.push('+'); + } im_str = im_str.replace(/^-/, ''); } result.push(im_str); @@ -5113,6 +5126,9 @@ if (this.__value__ === Number.POSITIVE_INFINITY) { return '+inf.0'; } + if (Number.isNaN(this.__value__)) { + return '+nan.0'; + } var str = this.__value__.toString(); if (!LNumber.isFloat(this.__value__) && !str.match(/e/i)) { var result = str + '.0'; @@ -6129,7 +6145,7 @@ 'true': true, 'false': false, 'null': null, - 'NaN': NaN, + 'NaN': LNumber(NaN), // ------------------------------------------------------------------ 'peek-char': doc('peek-char', function(port) { if (port) { diff --git a/templates/Makefile b/templates/Makefile index e4aa4017..bfde9baa 100755 --- a/templates/Makefile +++ b/templates/Makefile @@ -86,10 +86,10 @@ publish: jest-test: dist/lips.js @$(JEST) --coverage spec/*.spec.js -test: dist/lips.js dist/std.scm +test: dist/lips.js dist/std.min.scm @$(NPM) run test -test-file: dist/lips.js dist/std.scm +test-file: dist/lips.js dist/std.min.scm @$(NPM) run test -- -- -f $(FILE) test-update: dist/lips.js dist/std.scm diff --git a/tests/numbers.scm b/tests/numbers.scm index 00dfa94e..fadf6419 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -18,6 +18,15 @@ (t.is (/ (make-rectangular 1 2) (make-rectangular 2 10)) (/ 1+2i 2+10i)))) +(test "numbers: NaN" + (lambda (t) + (t.is (= +nan.0 +nan.0) false) + (t.is (eq? +nan.0 +nan.0) false) + (t.is (eqv? +nan.0 +nan.0) true) + (t.is (equal? +nan.0 +nan.0) true) + (t.is (eq? 10 +nan.0) false) + (t.is (eq? +nan.0 10) false))) + (test "numbers: complex NaN" (lambda (t) (t.is (number->string +nan.0+10i) "+nan.0+10i") @@ -36,6 +45,62 @@ (t.is (number->string 10.0-nan.0i) "10.0+nan.0i") (t.is (number->string 1/2-nan.0i) "1/2+nan.0i"))) +(test "numbers: operators + with NaN" + (lambda (t) + (t.is (+ +nan.0+nan.0i 10) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i 10.0) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i 1/2) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i +nan.0+nan.0i) +nan.0+nan.0i) + + (t.is (+ +nan.0+nan.0i 1/2+1/2i) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i 10+10i) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i 10.0+10.0i) +nan.0+nan.0i) + + (t.is (+ 10+nan.0i 10) 20+nan.0i) + (t.is (+ 10.0+nan.0i 10.0) 20.0+nan.0i) + (t.is (+ 1/2+nan.0i 1/2) 1+nan.0i) + + (t.is (+ 10+nan.0i 10) 20+nan.0i) + (t.is (+ 10.0+nan.0i 10.0) 20.0+nan.0i) + (t.is (+ 1/2+nan.0i 1/2) 1+nan.0i) + + (t.is (+ +nan.0i 10) 10+nan.0i) + (t.is (+ +nan.0i 10.0) 10.0+nan.0i) + (t.is (+ +nan.0i 1/2) 1/2+nan.0i) + (t.is (+ +nan.0i 10+10i) 10+nan.0i) + + (t.is (+ +nan.0 10) +nan.0) + (t.is (+ +nan.0 10.0) +nan.0) + (t.is (+ +nan.0 1/2) +nan.0) + (t.is (+ +nan.0 10+10i) +nan.0+10i) + ;; reversed + (t.is (+ 10 +nan.0+nan.0i) +nan.0+nan.0i) + (t.is (+ 10.0 +nan.0+nan.0i) +nan.0+nan.0i) + (t.is (+ 1/2 +nan.0+nan.0i) +nan.0+nan.0i) + (t.is (+ +nan.0+nan.0i +nan.0+nan.0i) +nan.0+nan.0i) + + (t.is (+ 1/2+1/2i +nan.0+nan.0i) +nan.0+nan.0i) + (t.is (+ 10+10i +nan.0+nan.0i) +nan.0+nan.0i) + (t.is (+ 10.0+10.0i +nan.0+nan.0i) +nan.0+nan.0i) + + (t.is (+ 10 10+nan.0i) 20+nan.0i) + (t.is (+ 10.0 10.0+nan.0i) 20.0+nan.0i) + (t.is (+ 1/2 1/2+nan.0i) 1+nan.0i) + + (t.is (+ 10 10+nan.0i) 20+nan.0i) + (t.is (+ 10.0 10.0+nan.0i) 20.0+nan.0i) + (t.is (+ 1/2 1/2+nan.0i) 1+nan.0i) + + (t.is (+ 10 +nan.0i) 10+nan.0i) + (t.is (+ 10.0 +nan.0i) 10.0+nan.0i) + (t.is (+ 1/2 +nan.0i) 1/2+nan.0i) + (t.is (+ 10+10i +nan.0i) 10+nan.0i) + + (t.is (+ 10 +nan.0) +nan.0) + (t.is (+ 10.0 +nan.0) +nan.0) + (t.is (+ 1/2 +nan.0) +nan.0) + (t.is (+ 10+10i +nan.0) +nan.0+10i))) + (test "numbers: complex infinity" (lambda (t) (t.is (number->string +inf.0+10i) "+inf.0+10i") @@ -91,8 +156,8 @@ (t.is (number->string (. (lips.parse "#i100") 0)) "100.0") (t.is (number->string (. (lips.parse "#i100i") 0)) "+100.0i") - (t.is (number->string (. (lips.parse "#i1/0") 0)) "Infinity") - (t.is (number->string (. (lips.parse "#i-1/0") 0)) "-Infinity") + (t.is (number->string (. (lips.parse "#i1/0") 0)) "+inf.0") + (t.is (number->string (. (lips.parse "#i-1/0") 0)) "-inf.0") (t.is #b100+100i 4+4i) (t.is (number->string 100) "100") @@ -493,12 +558,6 @@ (t.is (negative? -1/2) #t) (t.is (negative? -0.5) #t))) -(test "numbers: NaN" - (lambda (t) - (t.is (eq? NaN NaN) true) - (t.is (eq? 10 NaN) false) - (t.is (eq? NaN 10) false))) - (test "numbers: types" (lambda (t) (t.is (real? +nan.0) #t) From fade0635b55a7c9a0e3844dbdd47260d5c803f77 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Fri, 26 Feb 2021 15:31:18 +0100 Subject: [PATCH 048/109] unit tests for + operatio and inf.0 #34 --- tests/numbers.scm | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/numbers.scm b/tests/numbers.scm index fadf6419..353ded83 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -101,6 +101,62 @@ (t.is (+ 1/2 +nan.0) +nan.0) (t.is (+ 10+10i +nan.0) +nan.0+10i))) +(test "numbers: operators + with +inf.0" + (lambda (t) + (t.is (+ +inf.0+inf.0i 10) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i 10.0) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i 1/2) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i +inf.0+inf.0i) +inf.0+inf.0i) + + (t.is (+ +inf.0+inf.0i 1/2+1/2i) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i 10+10i) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i 10.0+10.0i) +inf.0+inf.0i) + + (t.is (+ 10+inf.0i 10) 20+inf.0i) + (t.is (+ 10.0+inf.0i 10.0) 20.0+inf.0i) + (t.is (+ 1/2+inf.0i 1/2) 1+inf.0i) + + (t.is (+ 10+inf.0i 10) 20+inf.0i) + (t.is (+ 10.0+inf.0i 10.0) 20.0+inf.0i) + (t.is (+ 1/2+inf.0i 1/2) 1+inf.0i) + + (t.is (+ +inf.0i 10) 10+inf.0i) + (t.is (+ +inf.0i 10.0) 10.0+inf.0i) + (t.is (+ +inf.0i 1/2) 1/2+inf.0i) + (t.is (+ +inf.0i 10+10i) 10+inf.0i) + + (t.is (+ +inf.0 10) +inf.0) + (t.is (+ +inf.0 10.0) +inf.0) + (t.is (+ +inf.0 1/2) +inf.0) + (t.is (+ +inf.0 10+10i) +inf.0+10i) + ;; reversed + (t.is (+ 10 +inf.0+inf.0i) +inf.0+inf.0i) + (t.is (+ 10.0 +inf.0+inf.0i) +inf.0+inf.0i) + (t.is (+ 1/2 +inf.0+inf.0i) +inf.0+inf.0i) + (t.is (+ +inf.0+inf.0i +inf.0+inf.0i) +inf.0+inf.0i) + + (t.is (+ 1/2+1/2i +inf.0+inf.0i) +inf.0+inf.0i) + (t.is (+ 10+10i +inf.0+inf.0i) +inf.0+inf.0i) + (t.is (+ 10.0+10.0i +inf.0+inf.0i) +inf.0+inf.0i) + + (t.is (+ 10 10+inf.0i) 20+inf.0i) + (t.is (+ 10.0 10.0+inf.0i) 20.0+inf.0i) + (t.is (+ 1/2 1/2+inf.0i) 1+inf.0i) + + (t.is (+ 10 10+inf.0i) 20+inf.0i) + (t.is (+ 10.0 10.0+inf.0i) 20.0+inf.0i) + (t.is (+ 1/2 1/2+inf.0i) 1+inf.0i) + + (t.is (+ 10 +inf.0i) 10+inf.0i) + (t.is (+ 10.0 +inf.0i) 10.0+inf.0i) + (t.is (+ 1/2 +inf.0i) 1/2+inf.0i) + (t.is (+ 10+10i +inf.0i) 10+inf.0i) + + (t.is (+ 10 +inf.0) +inf.0) + (t.is (+ 10.0 +inf.0) +inf.0) + (t.is (+ 1/2 +inf.0) +inf.0) + (t.is (+ 10+10i +inf.0) +inf.0+10i))) + (test "numbers: complex infinity" (lambda (t) (t.is (number->string +inf.0+10i) "+inf.0+10i") From a160443cdb9f011e43ff55bd710da575d71204ac Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sat, 27 Feb 2021 12:10:09 +0100 Subject: [PATCH 049/109] fix - operator + unit tests #34 Fix case when calculating sub on rational and complex Fix error messages for invalid numbers in complex op --- CHANGELOG.md | 1 + README.md | 4 +- dist/lips.js | 136 ++++++++++++++++++++++++++-------------------- dist/lips.min.js | 4 +- src/lips.js | 37 ++++++++----- tests/numbers.scm | 62 +++++++++++++++++++++ 6 files changed, 169 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index caa4f855..911c9621 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ * fix option -t --trace in Node REPL * fix `eqv?` on exact and inexact numbers according to R7RS spec * fix `exact->inexact` on complex numbers +* fix - operator ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 616f3ca6..464c6a21 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&ca413bb4e54e04c754d7d74c7a92ad7376c4075d)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&16b006fd82b5e9acd5fa1c8f60a3528d)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&fade0635b55a7c9a0e3844dbdd47260d5c803f77)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&eed852a6e0fd830750781c7a52c0b8be)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 09d1c5c7..73b3301a 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 26 Feb 2021 13:31:05 +0000 + * build: Sat, 27 Feb 2021 11:06:51 +0000 */ (function () { 'use strict'; @@ -7342,12 +7342,20 @@ LNumber.isComplex = function (n) { + if (!n) { + return false; + } + var ret = n instanceof LComplex || (LNumber.isNumber(n.im) || Number.isNaN(n.im)) && (LNumber.isNumber(n.re) || Number.isNaN(n.re)); return ret; }; // ------------------------------------------------------------------------- LNumber.isRational = function (n) { + if (!n) { + return false; + } + return n instanceof LRational || LNumber.isNumber(n.num) && LNumber.isNumber(n.denom); }; // ------------------------------------------------------------------------- @@ -7886,7 +7894,7 @@ LComplex.prototype.add = function (n) { - return this.complex_op(n, function (a_re, b_re, a_im, b_im) { + return this.complex_op('add', n, function (a_re, b_re, a_im, b_im) { return { re: a_re.add(b_re), im: a_im.add(b_im) @@ -7964,7 +7972,10 @@ re: n }); } else if (!LNumber.isComplex(n)) { - throw new Error('[LComplex::add] Invalid value'); + console.log({ + n: n + }); + throw new Error('[LComplex::div] Invalid value'); } var _this$coerce5 = this.coerce(n), @@ -7991,17 +8002,17 @@ LComplex.prototype.sub = function (n) { - return this.complex_op(n, function (a_re, b_re, a_im, b_im) { + return this.complex_op('sub', n, function (a_re, b_re, a_im, b_im) { return { re: a_re.sub(b_re), - im: a_im.add(b_im) + im: a_im.sub(b_im) }; }); }; // ------------------------------------------------------------------------- LComplex.prototype.mul = function (n) { - return this.complex_op(n, function (a_re, b_re, a_im, b_im) { + return this.complex_op('mul', n, function (a_re, b_re, a_im, b_im) { var ret = { re: a_re.mul(b_re).sub(a_im.mul(b_im)), im: a_re.mul(b_im).add(b_re.mul(a_im)) @@ -8011,7 +8022,23 @@ }; // ------------------------------------------------------------------------- - LComplex.prototype.complex_op = function (n, fn) { + LComplex.prototype.complex_op = function (name, n, fn) { + var _this5 = this; + + var calc = function calc(re, im) { + var ret = fn(_this5.__re__, re, _this5.__im__, im); + + if ('im' in ret && 're' in ret) { + return LComplex(ret, true); + } + + return ret; + }; + + if (typeof n === 'undefined') { + return calc(); + } + if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { if (!(n instanceof LNumber)) { n = LNumber(n); @@ -8024,19 +8051,12 @@ __re__: n }; } else if (!LNumber.isComplex(n)) { - throw new Error('[LComplex::add] Invalid value'); + throw new Error("[LComplex::".concat(name, "] Invalid value")); } var re = n.__re__ instanceof LNumber ? n.__re__ : this.__re__.asType(n.__re__); var im = n.__im__ instanceof LNumber ? n.__im__ : this.__im__.asType(n.__im__); - var ret = fn(this.__re__, re, this.__im__, im); - - if ('im' in ret && 're' in ret) { - var x = LComplex(ret, true); - return x; - } - - return ret; + return calc(re, im); }; // ------------------------------------------------------------------------- @@ -8674,7 +8694,7 @@ function InputPort(read) { - var _this5 = this; + var _this6 = this; if (typeof this !== 'undefined' && !(this instanceof InputPort) || typeof this === 'undefined') { return new InputPort(read); @@ -8688,22 +8708,22 @@ while (1) { switch (_context9.prev = _context9.next) { case 0: - if (_this5.char_ready()) { + if (_this6.char_ready()) { _context9.next = 5; break; } _context9.next = 3; - return _this5._read(); + return _this6._read(); case 3: line = _context9.sent; - _this5.__parser__ = new Parser(line, { - env: _this5 + _this6.__parser__ = new Parser(line, { + env: _this6 }); case 5: - return _context9.abrupt("return", _this5.__parser__); + return _context9.abrupt("return", _this6.__parser__); case 6: case "end": @@ -8789,14 +8809,14 @@ }; InputPort.prototype.close = function () { - var _this6 = this; + var _this7 = this; delete this.__parser__; // make content garbage collected, we assign null, // because the value is in prototype this._with_parser = null; ['read', 'close', 'read_char', 'peek-char', 'read_line'].forEach(function (name) { - _this6[name] = function () { + _this7[name] = function () { throw new Error('input-port: port is closed'); }; }); @@ -8845,7 +8865,7 @@ function OutputStringPort(toString) { - var _this7 = this; + var _this8 = this; if (typeof this !== 'undefined' && !(this instanceof OutputStringPort) || typeof this === 'undefined') { return new OutputStringPort(toString); @@ -8861,7 +8881,7 @@ x = x.valueOf(); } - _this7._buffer.push(x); + _this8._buffer.push(x); }; } @@ -8880,7 +8900,7 @@ OutputStringPort.prototype.constructor = OutputStringPort; // ------------------------------------------------------------------------- function OutputFilePort(filename, fd) { - var _this8 = this; + var _this9 = this; if (typeof this !== 'undefined' && !(this instanceof OutputFilePort) || typeof this === 'undefined') { return new OutputFilePort(filename, fd); @@ -8897,7 +8917,7 @@ x = x.valueOf(); } - _this8.fs('write')(_this8._fd, x, function () {}); + _this9.fs('write')(_this9._fd, x, function () {}); }; } @@ -8915,15 +8935,15 @@ }; OutputFilePort.prototype.close = function () { - var _this9 = this; + var _this10 = this; return new Promise(function (resolve, reject) { - _this9.fs('close')(_this9._fd, function (err) { + _this10.fs('close')(_this10._fd, function (err) { if (err) { reject(err); } else { - _this9._fd = null; - OutputPort.prototype.close.call(_this9); + _this10._fd = null; + OutputPort.prototype.close.call(_this10); resolve(); } }); @@ -8936,7 +8956,7 @@ function InputStringPort(string, env) { - var _this10 = this; + var _this11 = this; if (typeof this !== 'undefined' && !(this instanceof InputStringPort) || typeof this === 'undefined') { return new InputStringPort(string); @@ -8946,13 +8966,13 @@ env = env || global_env; string = string.valueOf(); this._with_parser = this._with_init_parser.bind(this, function () { - if (!_this10.__parser__) { - _this10.__parser__ = new Parser(string, { + if (!_this11.__parser__) { + _this11.__parser__ = new Parser(string, { env: env }); } - return _this10.__parser__; + return _this11.__parser__; }); this._make_defaults(); @@ -9223,13 +9243,13 @@ Environment.prototype.clone = function () { - var _this11 = this; + var _this12 = this; // duplicate refs var env = {}; // TODO: duplicated Symbols Object.keys(this.__env__).forEach(function (key) { - env[key] = _this11.__env__[key]; + env[key] = _this12.__env__[key]; }); return new Environment(env, this.__parent__, this.__name__); }; // ------------------------------------------------------------------------- @@ -9386,7 +9406,7 @@ Environment.prototype.constant = function (name, value) { - var _this12 = this; + var _this13 = this; if (this.__env__.hasOwnProperty(name)) { throw new Error("Environment::constant: ".concat(name, " already exists")); @@ -9395,7 +9415,7 @@ if (arguments.length === 1 && is_plain_object(arguments[0])) { var obj = arguments[0]; Object.keys(obj).forEach(function (key) { - _this12.constant(name, obj[key]); + _this13.constant(name, obj[key]); }); } else { Object.defineProperty(this.__env__, name, { @@ -9855,7 +9875,7 @@ }, "(cdr pair)\n\n Function returns cdr (tail) of the list/pair."), // ------------------------------------------------------------------ 'set!': doc(new Macro('set!', function (code) { - var _this13 = this; + var _this14 = this; var _ref28 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, dynamic_scope = _ref28.dynamic_scope, @@ -9930,7 +9950,7 @@ var key = parts.pop(); var name = parts.join('.'); - var obj = _this13.get(name, { + var obj = _this14.get(name, { throwError: false }); @@ -10435,7 +10455,7 @@ }, "(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."), // ------------------------------------------------------------------ 'eval': doc('eval', function (code, env) { - var _this14 = this; + var _this15 = this; env = env || this; return evaluate(code, { @@ -10443,13 +10463,13 @@ //dynamic_scope: this, error: function error(e) { var error = global_env.get('error'); - error.call(_this14, e.message); + error.call(_this15, e.message); if (e.code) { var stack = e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); }).join('\n'); - error.call(_this14, stack); + error.call(_this15, stack); } } }); @@ -11511,7 +11531,7 @@ }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ 'try': doc(new Macro('try', function (code, _ref38) { - var _this15 = this; + var _this16 = this; var dynamic_scope = _ref38.dynamic_scope, _error = _ref38.error; @@ -11545,9 +11565,9 @@ } var args = { - env: _this15, + env: _this16, error: function error(e) { - var env = _this15.inherit('try'); + var env = _this16.inherit('try'); if (catch_clause) { env.set(catch_clause.cdr.car.car, e); @@ -11557,7 +11577,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this15; + args.dynamic_scope = _this16; } unpromise(evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { @@ -11570,7 +11590,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this15; + args.dynamic_scope = _this16; } var result = evaluate(code.car, args); @@ -11630,7 +11650,7 @@ }, "(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."), // ------------------------------------------------------------------ map: doc(function map(fn) { - var _this16 = this; + var _this17 = this; for (var _len29 = arguments.length, lists = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { lists[_key29 - 1] = arguments[_key29]; @@ -11641,7 +11661,7 @@ lists.forEach(function (arg, i) { typecheck('map', arg, ['pair', 'nil'], i + 1); // detect cycles - if (arg instanceof Pair && !is_list.call(_this16, arg)) { + if (arg instanceof Pair && !is_list.call(_this17, arg)) { throw new Error("map: argument ".concat(i + 1, " is not a list")); } }); @@ -11663,7 +11683,7 @@ var env = this.newFrame(fn, args); env.set('parent.frame', parent_frame); return unpromise(fn.call.apply(fn, [env].concat(toConsumableArray(args))), function (head) { - return unpromise(map.call.apply(map, [_this16, fn].concat(toConsumableArray(lists.map(function (l) { + return unpromise(map.call.apply(map, [_this17, fn].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))), function (rest) { return new Pair(head, rest); @@ -11759,7 +11779,7 @@ }, "(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."), // ------------------------------------------------------------------ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { - var _this17 = this; + var _this18 = this; for (var _len32 = arguments.length, lists = new Array(_len32 > 3 ? _len32 - 3 : 0), _key33 = 3; _key33 < _len32; _key33++) { lists[_key33 - 3] = arguments[_key33]; @@ -11779,7 +11799,7 @@ return unpromise(fn.apply(void 0, toConsumableArray(lists.map(function (l) { return l.car; })).concat([init])), function (value) { - return reduce.call.apply(reduce, [_this17, fn, value].concat(toConsumableArray(lists.map(function (l) { + return reduce.call.apply(reduce, [_this18, fn, value].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))); }); @@ -13302,10 +13322,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 26 Feb 2021 13:31:05 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 27 Feb 2021 11:06:51 +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('Fri, 26 Feb 2021 13:31:05 +0000').valueOf(); + var date = LString('Sat, 27 Feb 2021 11:06:51 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13345,7 +13365,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 26 Feb 2021 13:31:05 +0000', + date: 'Sat, 27 Feb 2021 11:06:51 +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 e6697b12..4def7cc1 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 26 Feb 2021 13:31:05 +0000 + * build: Sat, 27 Feb 2021 11:06:51 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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){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){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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op(e,function(e,r,n,t){return{re:e.sub(r),im:n.add(t)}})};LComplex.prototype.mul=function(e){return this.complex_op(e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){if(!(e instanceof LNumber)){e=LNumber(e)}var n=e.asType(0);e={__im__:n,__re__:e}}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::add] Invalid value")}var t=e.__re__ instanceof LNumber?e.__re__:this.__re__.asType(e.__re__);var i=e.__im__ instanceof LNumber?e.__im__:this.__im__.asType(e.__im__);var a=r(this.__re__,t,this.__im__,i);if("im"in a&&"re"in a){var u=LComplex(a,true);return u}return a};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Fri, 26 Feb 2021 13:31:05 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Fri, 26 Feb 2021 13:31:05 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){console.log({n:e});throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 27 Feb 2021 11:06:51 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sat, 27 Feb 2021 11:06:51 +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,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/src/lips.js b/src/lips.js index 4b2ee7cf..f92b4b6e 100644 --- a/src/lips.js +++ b/src/lips.js @@ -4521,6 +4521,9 @@ }; // ------------------------------------------------------------------------- LNumber.isComplex = function(n) { + if (!n) { + return false; + } var ret = n instanceof LComplex || ((LNumber.isNumber(n.im) || Number.isNaN(n.im)) && (LNumber.isNumber(n.re) || Number.isNaN(n.re))); @@ -4528,6 +4531,9 @@ }; // ------------------------------------------------------------------------- LNumber.isRational = function(n) { + if (!n) { + return false; + } return n instanceof LRational || (LNumber.isNumber(n.num) && LNumber.isNumber(n.denom)); }; @@ -4930,7 +4936,7 @@ }; // ------------------------------------------------------------------------- LComplex.prototype.add = function(n) { - return this.complex_op(n, function(a_re, b_re, a_im, b_im) { + return this.complex_op('add', n, function(a_re, b_re, a_im, b_im) { return { re: a_re.add(b_re), im: a_im.add(b_im) @@ -4990,7 +4996,7 @@ if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { n = LComplex({ im: 0, re: n }); } else if (!LNumber.isComplex(n)) { - throw new Error('[LComplex::add] Invalid value'); + throw new Error('[LComplex::div] Invalid value'); } const [ a, b ] = this.coerce(n); const conj = LComplex({ re: b.__re__, im: b.__im__.sub() }); @@ -5002,16 +5008,16 @@ }; // ------------------------------------------------------------------------- LComplex.prototype.sub = function(n) { - return this.complex_op(n, function(a_re, b_re, a_im, b_im) { + return this.complex_op('sub', n, function(a_re, b_re, a_im, b_im) { return { re: a_re.sub(b_re), - im: a_im.add(b_im) + im: a_im.sub(b_im) }; }); }; // ------------------------------------------------------------------------- LComplex.prototype.mul = function(n) { - return this.complex_op(n, function(a_re, b_re, a_im, b_im) { + return this.complex_op('mul', n, function(a_re, b_re, a_im, b_im) { var ret = { re: a_re.mul(b_re).sub(a_im.mul(b_im)), im: a_re.mul(b_im).add(b_re.mul(a_im)) @@ -5020,7 +5026,17 @@ }); }; // ------------------------------------------------------------------------- - LComplex.prototype.complex_op = function(n, fn) { + LComplex.prototype.complex_op = function(name, n, fn) { + const calc = (re, im) => { + var ret = fn(this.__re__, re, this.__im__, im); + if ('im' in ret && 're' in ret) { + return LComplex(ret, true); + } + return ret; + }; + if (typeof n === 'undefined') { + return calc(); + } if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { if (!(n instanceof LNumber)) { n = LNumber(n); @@ -5028,16 +5044,11 @@ const im = n.asType(0); n = { __im__: im, __re__: n }; } else if (!LNumber.isComplex(n)) { - throw new Error('[LComplex::add] Invalid value'); + throw new Error(`[LComplex::${name}] Invalid value`); } var re = n.__re__ instanceof LNumber ? n.__re__ : this.__re__.asType(n.__re__); var im = n.__im__ instanceof LNumber ? n.__im__ : this.__im__.asType(n.__im__); - var ret = fn(this.__re__, re, this.__im__, im); - if ('im' in ret && 're' in ret) { - var x = LComplex(ret, true); - return x; - } - return ret; + return calc(re, im); }; // ------------------------------------------------------------------------- LComplex._op = { diff --git a/tests/numbers.scm b/tests/numbers.scm index 353ded83..515dbacd 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -491,6 +491,68 @@ (t.is (+ 1/2+0.1i 1/2) 1+0.1i) (t.is (+ 1/2+0.1i 0.1) 0.6+0.1i))) +(test "numbers: operators -" + (lambda (t) + (t.is (- 1 1.0 1/10) -0.1) + (t.is (number->string (- 1/2 1/2 1.0)) "-1.0") + + (t.is (number->string (- 1 1)) "0") + (t.is (number->string (- 1.0 1)) "0.0") + (t.is (number->string (- 1 1.0)) "0.0") + + (t.is (number->string (- 1 1.1)) "-0.10000000000000009") + (t.is (number->string (- 1.1 1)) "0.10000000000000009") + + (t.is (number->string (- 1/2 1/3)) "1/6") + (t.is (number->string (- 1 1/2)) "1/2") + (t.is (number->string (- 1/2 1)) "-1/2") + + (t.is (number->string (- 1.1 1/2)) "0.6000000000000001") + (t.is (number->string (- 1/2 1.1)) "-0.6000000000000001") + + (t.is (- 0.1 +10i) 0.1-10.0i) + (t.is (- 10 +0.01i) 10-0.01i) + (t.is (- 1/10 +0.01i) 1/10-0.01i) + (t.is (- 0.01 +1/10i) 0.01-1/10i) + (t.is (- 1/10 #b100i) 1/10-4i) + (t.is (- #b100 +1/10i) 4-1/10i) + + (t.is (- 10 1) 9) + (t.is (- 10 1/2) 19/2) + (t.is (- 10 0.1) 9.9) + (t.is (- 10 10+10i) -10i) + (t.is (- 10 1/2+1/2i) 19/2-1/2i) + (t.is (- 10 0.1+0.1i) 9.9-0.1i) + + (t.is (- 10+10i 1/2) 19/2+10i) + (t.is (- 10+10i 0.1) 9.9+10.0i) + (t.is (- 10+10i 10) +10i) + + (t.is (- 0.1+0.1i 1/2) -0.4+0.1i) + (t.is (- 0.1+0.1i 0.1) +0.1i) + (t.is (- 0.1+0.1i 10) -9.9+0.1i) + + (t.is (- 1/2+1/2i 1/2) 1/2i) + (t.is (- 1/2+1/2i 0.1) 0.4+1/2i) + (t.is (- 1/2+1/2i 10) -19/2+1/2i) + + ;; mixed + (t.is (- 10+1/2i 10) +1/2i) + (t.is (- 10+1/2i 1/2) 19/2+1/2i) + (t.is (- 10+1/2i 0.1) 9.9+1/2i) + + (t.is (- 10+0.1i 10) +0.1i) + (t.is (- 10+0.1i 1/2) 19/2+0.1i) + (t.is (- 10+0.1i 0.1) 9.9+0.1i) + + (t.is (- 1/2+10i 10) -19/2+10i) + (t.is (- 1/2+10i 1/2) +10i) + (t.is (- 1/2+10i 0.1) 0.4+10.0i) + + (t.is (- 1/2+0.1i 10) -19/2+0.1i) + (t.is (- 1/2+0.1i 1/2) 0.1i) + (t.is (- 1/2+0.1i 0.1) 0.4+0.1i))) + (test "numbers: operators /" (lambda (t) (t.is (/ 10 10) 1) From 19522e002b7a0889045c369a130b95d4feada546 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sat, 27 Feb 2021 12:14:19 +0100 Subject: [PATCH 050/109] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 911c9621..3d1962eb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ * fix option -t --trace in Node REPL * fix `eqv?` on exact and inexact numbers according to R7RS spec * fix `exact->inexact` on complex numbers -* fix - operator +* fix arithmetic with single complex value ## 1.0.0-beta.11 ### Breaking From b782d95f08bfc1bc72950403fbace9d906d0f1db Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sat, 27 Feb 2021 12:42:56 +0100 Subject: [PATCH 051/109] unit tests for operatation * #34 --- README.md | 4 ++-- dist/lips.js | 11 ++++------ dist/lips.min.js | 4 ++-- tests/numbers.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 464c6a21..14251263 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&fade0635b55a7c9a0e3844dbdd47260d5c803f77)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&eed852a6e0fd830750781c7a52c0b8be)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&19522e002b7a0889045c369a130b95d4feada546)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7aa0729980eb3bc2d57cc8a2314bddf1)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 73b3301a..80c5ee32 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 27 Feb 2021 11:06:51 +0000 + * build: Sat, 27 Feb 2021 11:38:50 +0000 */ (function () { 'use strict'; @@ -7972,9 +7972,6 @@ re: n }); } else if (!LNumber.isComplex(n)) { - console.log({ - n: n - }); throw new Error('[LComplex::div] Invalid value'); } @@ -13322,10 +13319,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 27 Feb 2021 11:06:51 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 27 Feb 2021 11:38:50 +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('Sat, 27 Feb 2021 11:06:51 +0000').valueOf(); + var date = LString('Sat, 27 Feb 2021 11:38:50 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13365,7 +13362,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 27 Feb 2021 11:06:51 +0000', + date: 'Sat, 27 Feb 2021 11:38:50 +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 4def7cc1..451ff08b 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 27 Feb 2021 11:06:51 +0000 + * build: Sat, 27 Feb 2021 11:38:50 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){console.log({n:e});throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 27 Feb 2021 11:06:51 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sat, 27 Feb 2021 11:06:51 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 27 Feb 2021 11:38:50 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sat, 27 Feb 2021 11:38:50 +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,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/tests/numbers.scm b/tests/numbers.scm index 515dbacd..81d746e4 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -605,6 +605,58 @@ (t.is (/ 1.0 1/2+1.0i) 0.4-0.8i) (t.is (/ 1.0 1/2+1i) 0.4-0.8i))) +(test "numbers: operators *" + (lambda (t) + (t.is (* 10 10) 100) + (t.is (* 10 1/10) 1) + (t.is (* 10 2) 20) + (t.is (* 10 1/3) 10/3) + (t.is (* 10 2.0) 20.0) + + (t.is (* 2 10+10i) 20+20i) + (t.is (* 2 10+10.0i) 20+20.0i) + (t.is (* 2 10+1/10i) 20+1/5i) + + (t.is (* 2 1.0+1.0i) 2.0+2.0i) + (t.is (* 2 1.0+1i) 2.0+2.0i) + (t.is (* 2.0+1/2i) 2.0+0.5i) + + (t.is (* 2 1/10+1/10i) 1/5+1/5i) + (t.is (* 2 1/10+1i) 1/5+2i) + (t.is (* 2 1/2+1.0i) 1+2.0i) + + (t.is (* 1/2 10) 5) + (t.is (* 1/2 10.0) 5.0) + (t.is (* 1/2 1/2) 1/4) + + (t.is (* 1/2 10+10i) 5+5i) + (t.is (* 1/2 1+2.0i) 1/2+1.0i) + (t.is (* 1/2 1+1/2i) 1/2+1/4i) + + (t.is (* 1/2 10.0+10.0i) 5.0+5.0i) + (t.is (* 1/2 10.0+10i) 5.0+5i) + (t.is (* 1/2 1.0+1/2i) 0.5+1/4i) + + (t.is (* 1/2 1/20+1/20i) 1/40+1/40i) + (t.is (* 1/2 1/2+1i) 1/4+1/2i) + (t.is (* 1/2 1/2+1.0i) 1/4+0.5i) + + (t.is (* 1.0 1.0) 1.0) + (t.is (* 1.0 2) 2.0) + (t.is (* 1.0 1/10) 0.1) + + (t.is (* 1.0 1+1i) 1.0+1.0i) + (t.is (* 1.0 1+1.0i) 1.0+1.0i) + (t.is (* 1.0 1+1/2i) 1.0+0.5i) + + (t.is (* 1.0 1.0+1.0i) 1.0+1.0i) + (t.is (* 1.0 1.0+1i) 1.0+1.0i) + (t.is (* 1.0 1.0+1/2i) 1.0+0.5i) + + (t.is (* 1.0 1/2+1/2i) 0.5+0.5i) + (t.is (* 1.0 1/2+1.0i) 0.5+1.0i) + (t.is (* 1.0 1/2+1i) 0.5+1.0i))) + (test "numbers: sqrt" (lambda (t) (for-each (lambda (x) From 9c0cd4195109f281469fef7e339c5810076f69ae Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sun, 28 Feb 2021 11:54:15 +0100 Subject: [PATCH 052/109] fix creating environment with just the name --- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/lips.js b/dist/lips.js index 80c5ee32..e5f2a07f 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 27 Feb 2021 11:38:50 +0000 + * build: Sun, 28 Feb 2021 10:53:40 +0000 */ (function () { 'use strict'; @@ -9103,7 +9103,7 @@ parent = null; } else if (typeof arguments[0] === 'string') { obj = {}; - parent = {}; + parent = null; name = arguments[0]; } } @@ -13319,10 +13319,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 27 Feb 2021 11:38:50 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 28 Feb 2021 10:53:40 +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('Sat, 27 Feb 2021 11:38:50 +0000').valueOf(); + var date = LString('Sun, 28 Feb 2021 10:53:40 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13362,7 +13362,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 27 Feb 2021 11:38:50 +0000', + date: 'Sun, 28 Feb 2021 10:53:40 +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 451ff08b..82f26cd4 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 27 Feb 2021 11:38:50 +0000 + * build: Sun, 28 Feb 2021 10:53:40 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r={};n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sat, 27 Feb 2021 11:38:50 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sat, 27 Feb 2021 11:38:50 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 28 Feb 2021 10:53:40 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sun, 28 Feb 2021 10:53:40 +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,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/src/lips.js b/src/lips.js index f92b4b6e..75bc85e0 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5774,7 +5774,7 @@ parent = null; } else if (typeof arguments[0] === 'string') { obj = {}; - parent = {}; + parent = null; name = arguments[0]; } } From 47584a1610de8e65204710526f7896e4e9b2dd2c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sun, 28 Feb 2021 11:55:40 +0100 Subject: [PATCH 053/109] add `environment?` + base library system #129 --- CHANGELOG.md | 1 + README.md | 2 +- dist/std.min.scm | 14 +++++- dist/std.scm | 120 ++++++++++++++++++++++++++++++++++++++++++++++ lib/R7RS.scm | 113 +++++++++++++++++++++++++++++++++++++++++++ lib/bootstrap.scm | 7 +++ 6 files changed, 254 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d1962eb..8e3fce67 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * add `nan?`, `infinite?` and `finite?` functions * add `+nan.0` and `-nan.0` (R7RS) * properly handle negative inexact zero +* new `environment?` function ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/README.md b/README.md index 14251263..e25efbc0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&19522e002b7a0889045c369a130b95d4feada546)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&b782d95f08bfc1bc72950403fbace9d906d0f1db)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7aa0729980eb3bc2d57cc8a2314bddf1)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/std.min.scm b/dist/std.min.scm index 5acb90c7..cafeb37b 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -270,7 +270,9 @@ throw exception that function is not yet implemented." (quasiquote (new lips.Env | | | | / \\ | | __| | | | | | __| | | | | | | | / /\\ \\ | | | | | | | | | | | | + |_| + /_/ \\_\\ + |_| + + |_| |_| + + + - \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define (environment? obj) "(environment? obj) + +Function check if object is LIPS environment." (instanceof lips.Environment obj))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) Macro that creates special symbol macro for evaluator similar to build in , or `. It's like alias for real macro. Similar to CL reader macros but it receive already @@ -719,4 +721,12 @@ Function check if argument x is Not a Number (NaN) value." (and (number? x) (or Function check if value is infinite." (or (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (number? x) (not (eq? x NaN)) (%number-type "complex" x) (or (infinite? (real-part x)) (infinite? (imag-part x))))))(define (finite? x) "(finite? x) -Function check if value is finite." (not (infinite? x))) \ No newline at end of file +Function check if value is finite." (not (infinite? x)))(define-class %Library Object (constructor (lambda (self name) (set! self.__namespace__ &()) (set! self.__name__ name))) (append (lambda (self namespace env) (if (environment? (. self.__namespace__ namespace)) (throw (new Error (string-append "namespace " namespace " already exists in library " self.__name__))) (set-obj! self.__namespace__ namespace env)))) (env (lambda (self namespace) (let ((env (. self.__namespace__ namespace))) (if (not (environment? env)) (throw (new Error (string-append "namespace " namespace " sdon't exists"))) env)))) (get (lambda (self namespace name) (--> (self.env namespace) (get name)))) (set (lambda (self namespace name value) (--> (self.env namespace) (set name value)))) (toString (lambda (self) (string-append "#"))))(define (%import-name library namespace names) (quasiquote (begin (unquote-splicing (map (lambda (name) (quasiquote (define (unquote name) (--> (unquote library) (get (quote (unquote namespace)) (quote (unquote name))))))) names)))))(define-macro (import . specs) "(import (library namespace)) +(import (only (library namespace) name1 name2)) + +Macro for importing names from library." (let ((parent (current-environment))) (quasiquote (begin (unquote-splicing (map (lambda (spec) (if (not (pair? spec)) (throw (new Error "import: invalid syntax")) (cond ((symbol=? (car spec) (quote only)) (let ((lib (caadr spec)) (namespace (caaddr spec))) (if (pair? (cadr spec)) (%import-name (unquote lib) (quote (unquote namespace)) (quote (unquote (caddr spec)))) (throw (new Error "import: invalid syntax"))))) (else (let* ((lib-name (car spec)) (lib (parent.get lib-name)) (namespace (cadr spec))) (%import-name lib-name namespace (env (lib.env namespace)))))))) specs))))))(define (new-library name namespace) "(new-library name) + +Create new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib))(define-macro (define-library spec . body) "(define-library (library (name namespace) . body) + +Macro for defining modules inside you can use define to create functions. +And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote (unquote module-var)) (set (quote (unquote (unquote namespace-var))) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote (unquote module-var)) (set (quote (unquote (unquote namespace-var))) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) body))))) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index 21ae260c..0a6c1336 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1225,6 +1225,13 @@ (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) ;; --------------------------------------------------------------------------------------- +(define (environment? obj) + "(environment? obj) + + Function check if object is LIPS environment." + (instanceof lips.Environment obj)) + +;; --------------------------------------------------------------------------------------- ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ ;; | | \ \ | | | || . \/ __> | | @@ -3585,3 +3592,116 @@ (not (infinite? x))) ;; ----------------------------------------------------------------------------- +(define-class %Library Object + (constructor + (lambda (self name) + (set! self.__namespace__ &()) + (set! self.__name__ name))) + (append + (lambda (self namespace env) + (if (environment? (. self.__namespace__ namespace)) + (throw (new Error (string-append "namespace " namespace + " already exists in library " + self.__name__))) + (set-obj! self.__namespace__ namespace env)))) + (env + (lambda (self namespace) + (let ((env (. self.__namespace__ namespace))) + (if (not (environment? env)) + (throw (new Error (string-append "namespace " namespace " sdon't exists"))) + env)))) + (get + (lambda (self namespace name) + (--> (self.env namespace) (get name)))) + (set + (lambda (self namespace name value) + (--> (self.env namespace) (set name value)))) + (toString + (lambda (self) + (string-append "#")))) + +;; ----------------------------------------------------------------------------- +(define (%import-name library namespace names) + `(begin + ,@(map (lambda (name) + `(define ,name (--> ,library (get ',namespace ',name)))) + names))) + +;; ----------------------------------------------------------------------------- +(define-macro (import . specs) + "(import (library namespace)) + (import (only (library namespace) name1 name2)) + + Macro for importing names from library." + (let ((parent (current-environment))) + `(begin + ,@(map (lambda (spec) + (if (not (pair? spec)) + (throw (new Error "import: invalid syntax")) + (cond ((symbol=? (car spec) + 'only) + (let ((lib (caadr spec)) + (namespace (caaddr spec))) + (if (pair? (cadr spec)) + (%import-name ,lib + ',namespace + ',(caddr spec)) + (throw (new Error "import: invalid syntax"))))) + (else + (let* ((lib-name (car spec)) + (lib (parent.get lib-name)) + (namespace (cadr spec))) + (%import-name lib-name + namespace + (env (lib.env namespace)))))))) + specs)))) + +;; ----------------------------------------------------------------------------- +(define (new-library name namespace) + "(new-library name) + + Create new empty library object with empty namespace." + (let* ((parent (. (current-environment) '__parent__)) + (lib (let ((lib (--> parent (get name &(:throwError false))))) + (if (null? lib) + (new %Library name) + lib))) + (x (new lips.Environment + (string-append "library-" + (--> name (toLowerCase)) + "-" + (--> namespace (toLowerCase)))))) + (lib.append namespace x) + lib)) + +;; ----------------------------------------------------------------------------- +(define-macro (define-library spec . body) + "(define-library (library (name namespace) . body) + + Macro for defining modules inside you can use define to create functions. + And use export name to add that name to defined environment." + (let ((parent (. (current-environment) '__parent__)) + (module-var (gensym)) + (namespace-var (gensym)) + (name (car spec)) + (namespace (cadr spec))) + `(let ((,module-var (new-library ,(symbol->string name) + ,(symbol->string namespace))) + (,namespace-var ',namespace)) + (define-macro (export . body) + `(begin + ,@(map (lambda (expr) + (cond ((symbol? expr) + `(--> ,,module-var (set ',,namespace-var + ',expr + ,expr))) + ((and (pair? expr) (symbol=? (car expr) + 'rename)) + `(--> ,,module-var (set ',,namespace-var + ',(cadr expr) + ,(caddr expr)))))) + body))) + ,@body + (--> ,parent (set ',name ,module-var))))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/R7RS.scm b/lib/R7RS.scm index b938663c..6289ac87 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -804,3 +804,116 @@ (not (infinite? x))) ;; ----------------------------------------------------------------------------- +(define-class %Library Object + (constructor + (lambda (self name) + (set! self.__namespace__ &()) + (set! self.__name__ name))) + (append + (lambda (self namespace env) + (if (environment? (. self.__namespace__ namespace)) + (throw (new Error (string-append "namespace " namespace + " already exists in library " + self.__name__))) + (set-obj! self.__namespace__ namespace env)))) + (env + (lambda (self namespace) + (let ((env (. self.__namespace__ namespace))) + (if (not (environment? env)) + (throw (new Error (string-append "namespace " namespace " sdon't exists"))) + env)))) + (get + (lambda (self namespace name) + (--> (self.env namespace) (get name)))) + (set + (lambda (self namespace name value) + (--> (self.env namespace) (set name value)))) + (toString + (lambda (self) + (string-append "#")))) + +;; ----------------------------------------------------------------------------- +(define (%import-name library namespace names) + `(begin + ,@(map (lambda (name) + `(define ,name (--> ,library (get ',namespace ',name)))) + names))) + +;; ----------------------------------------------------------------------------- +(define-macro (import . specs) + "(import (library namespace)) + (import (only (library namespace) name1 name2)) + + Macro for importing names from library." + (let ((parent (current-environment))) + `(begin + ,@(map (lambda (spec) + (if (not (pair? spec)) + (throw (new Error "import: invalid syntax")) + (cond ((symbol=? (car spec) + 'only) + (let ((lib (caadr spec)) + (namespace (caaddr spec))) + (if (pair? (cadr spec)) + (%import-name ,lib + ',namespace + ',(caddr spec)) + (throw (new Error "import: invalid syntax"))))) + (else + (let* ((lib-name (car spec)) + (lib (parent.get lib-name)) + (namespace (cadr spec))) + (%import-name lib-name + namespace + (env (lib.env namespace)))))))) + specs)))) + +;; ----------------------------------------------------------------------------- +(define (new-library name namespace) + "(new-library name) + + Create new empty library object with empty namespace." + (let* ((parent (. (current-environment) '__parent__)) + (lib (let ((lib (--> parent (get name &(:throwError false))))) + (if (null? lib) + (new %Library name) + lib))) + (x (new lips.Environment + (string-append "library-" + (--> name (toLowerCase)) + "-" + (--> namespace (toLowerCase)))))) + (lib.append namespace x) + lib)) + +;; ----------------------------------------------------------------------------- +(define-macro (define-library spec . body) + "(define-library (library (name namespace) . body) + + Macro for defining modules inside you can use define to create functions. + And use export name to add that name to defined environment." + (let ((parent (. (current-environment) '__parent__)) + (module-var (gensym)) + (namespace-var (gensym)) + (name (car spec)) + (namespace (cadr spec))) + `(let ((,module-var (new-library ,(symbol->string name) + ,(symbol->string namespace))) + (,namespace-var ',namespace)) + (define-macro (export . body) + `(begin + ,@(map (lambda (expr) + (cond ((symbol? expr) + `(--> ,,module-var (set ',,namespace-var + ',expr + ,expr))) + ((and (pair? expr) (symbol=? (car expr) + 'rename)) + `(--> ,,module-var (set ',,namespace-var + ',(cadr expr) + ,(caddr expr)))))) + body))) + ,@body + (--> ,parent (set ',name ,module-var))))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 25b3f468..94715ca0 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1225,3 +1225,10 @@ (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) ;; --------------------------------------------------------------------------------------- +(define (environment? obj) + "(environment? obj) + + Function check if object is LIPS environment." + (instanceof lips.Environment obj)) + +;; --------------------------------------------------------------------------------------- From eb1ec20f19611017e2f2878a33d61601e77a1568 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sun, 28 Feb 2021 12:16:23 +0100 Subject: [PATCH 054/109] refactor export macro inside define-library #129 --- dist/std.min.scm | 4 ++-- dist/std.scm | 28 ++++++++++++++++------------ lib/R7RS.scm | 28 ++++++++++++++++------------ 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index cafeb37b..0ce148d5 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -726,7 +726,7 @@ Function check if value is finite." (not (infinite? x)))(define-class %Library O Macro for importing names from library." (let ((parent (current-environment))) (quasiquote (begin (unquote-splicing (map (lambda (spec) (if (not (pair? spec)) (throw (new Error "import: invalid syntax")) (cond ((symbol=? (car spec) (quote only)) (let ((lib (caadr spec)) (namespace (caaddr spec))) (if (pair? (cadr spec)) (%import-name (unquote lib) (quote (unquote namespace)) (quote (unquote (caddr spec)))) (throw (new Error "import: invalid syntax"))))) (else (let* ((lib-name (car spec)) (lib (parent.get lib-name)) (namespace (cadr spec))) (%import-name lib-name namespace (env (lib.env namespace)))))))) specs))))))(define (new-library name namespace) "(new-library name) -Create new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib))(define-macro (define-library spec . body) "(define-library (library (name namespace) . body) +Create new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib))(define (%export module namespace specs) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) specs)))))(define-macro (define-library spec . body) "(define-library (library (name namespace) . body) Macro for defining modules inside you can use define to create functions. -And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote (unquote module-var)) (set (quote (unquote (unquote namespace-var))) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote (unquote module-var)) (set (quote (unquote (unquote namespace-var))) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) body))))) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) \ No newline at end of file +And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index 0a6c1336..0dde7f84 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3674,6 +3674,21 @@ (lib.append namespace x) lib)) +;; ----------------------------------------------------------------------------- +(define (%export module namespace specs) + `(begin + ,@(map (lambda (expr) + (cond ((symbol? expr) + `(--> ,module (set ',namespace + ',expr + ,expr))) + ((and (pair? expr) (symbol=? (car expr) + 'rename)) + `(--> ,module (set ',namespace + ',(cadr expr) + ,(caddr expr)))))) + specs))) + ;; ----------------------------------------------------------------------------- (define-macro (define-library spec . body) "(define-library (library (name namespace) . body) @@ -3689,18 +3704,7 @@ ,(symbol->string namespace))) (,namespace-var ',namespace)) (define-macro (export . body) - `(begin - ,@(map (lambda (expr) - (cond ((symbol? expr) - `(--> ,,module-var (set ',,namespace-var - ',expr - ,expr))) - ((and (pair? expr) (symbol=? (car expr) - 'rename)) - `(--> ,,module-var (set ',,namespace-var - ',(cadr expr) - ,(caddr expr)))))) - body))) + (%export ,module-var ,namespace-var body)) ,@body (--> ,parent (set ',name ,module-var))))) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 6289ac87..4183a295 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -886,6 +886,21 @@ (lib.append namespace x) lib)) +;; ----------------------------------------------------------------------------- +(define (%export module namespace specs) + `(begin + ,@(map (lambda (expr) + (cond ((symbol? expr) + `(--> ,module (set ',namespace + ',expr + ,expr))) + ((and (pair? expr) (symbol=? (car expr) + 'rename)) + `(--> ,module (set ',namespace + ',(cadr expr) + ,(caddr expr)))))) + specs))) + ;; ----------------------------------------------------------------------------- (define-macro (define-library spec . body) "(define-library (library (name namespace) . body) @@ -901,18 +916,7 @@ ,(symbol->string namespace))) (,namespace-var ',namespace)) (define-macro (export . body) - `(begin - ,@(map (lambda (expr) - (cond ((symbol? expr) - `(--> ,,module-var (set ',,namespace-var - ',expr - ,expr))) - ((and (pair? expr) (symbol=? (car expr) - 'rename)) - `(--> ,,module-var (set ',,namespace-var - ',(cadr expr) - ,(caddr expr)))))) - body))) + (%export ,module-var ,namespace-var body)) ,@body (--> ,parent (set ',name ,module-var))))) From 2580adf9a4633a1263a0915305033bb254045fcb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz Date: Sun, 28 Feb 2021 15:27:39 +0100 Subject: [PATCH 055/109] fix parsing regex + unit tests from jest #39 Fix parsing regex that have escape slash and parentheis (e.g. `#/( \\/)/g`) Move tokenizer unit tests from Jest to Ava --- CHANGELOG.md | 1 + README.md | 4 +- dist/lips.js | 10 +- dist/lips.min.js | 4 +- spec/lips.spec.js | 118 ---- src/lips.js | 1 + tests/parser.scm | 38 ++ tests/ports.scm | 2 +- tests/snapshots/test.js.md | 1222 ++++++++++++++++++++++++++++++++++ tests/snapshots/test.js.snap | Bin 14008 -> 18407 bytes tests/stubs/macro.txt | 10 + 11 files changed, 1282 insertions(+), 128 deletions(-) create mode 100644 tests/stubs/macro.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e3fce67..cd00c1ec 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ * fix `eqv?` on exact and inexact numbers according to R7RS spec * fix `exact->inexact` on complex numbers * fix arithmetic with single complex value +* fix parsing regex that have escape slash and parenthesis (`#/( \\/)/g`) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index e25efbc0..ebfc8494 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&b782d95f08bfc1bc72950403fbace9d906d0f1db)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7aa0729980eb3bc2d57cc8a2314bddf1)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&eb1ec20f19611017e2f2878a33d61601e77a1568)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&388ce272c1300b132657adb1d2190a85)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index e5f2a07f..77eda81d 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 10:53:40 +0000 + * build: Sun, 28 Feb 2021 14:26:21 +0000 */ (function () { 'use strict'; @@ -2698,7 +2698,7 @@ [/#/, null, /[bdxoeitf]/i, null, Lexer.symbol], // characters [/#/, null, /\\/, null, Lexer.character], [/\\/, /#/, /\s/, Lexer.character, Lexer.character], [/\\/, /#/, /[()[\]]/, Lexer.character, Lexer.character], [/\s/, /\\/, null, Lexer.character, null], [/\S/, null, Lexer.boundary, Lexer.character, null], // brackets [/[()[\]]/, null, null, null, null], // regex - [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null]]; // ---------------------------------------------------------------------- + [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null]]; // ---------------------------------------------------------------------- // :: symbols should be matched last // ---------------------------------------------------------------------- @@ -13319,10 +13319,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 28 Feb 2021 10:53:40 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 28 Feb 2021 14:26:21 +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('Sun, 28 Feb 2021 10:53:40 +0000').valueOf(); + var date = LString('Sun, 28 Feb 2021 14:26:21 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13362,7 +13362,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 28 Feb 2021 10:53:40 +0000', + date: 'Sun, 28 Feb 2021 14:26:21 +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 82f26cd4..806eddb2 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 10:53:40 +0000 + * build: Sun, 28 Feb 2021 14:26:21 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 28 Feb 2021 10:53:40 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sun, 28 Feb 2021 10:53:40 +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,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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);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 u=l.call(i,"catchLoc");var o=l.call(i,"finallyLoc");if(u&&o){if(this.prev=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n=55296&&i<=56319&&n1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.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(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!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),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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 n=r.__name__;if(LString.isString(n)){n=n.toString();return"#")}return"#"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="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 n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){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 f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#")}return"#"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#")}return"#"}if(_!==""){return"#<"+_+">"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,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 n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t")}return"#"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t2?t-2:0),a=2;a1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n1?e-1:0),n=1;n=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n0){n.push(this.__string__.substring(0,e))}n.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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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 n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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 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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#")};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]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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 n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?n-1:0),i=1;it.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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 t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+11){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(rn){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;iarray")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(iarray")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;iarray").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i1?r-1:0),a=1;a3?t-3:0),a=3;a3?i-3:0),u=3;uarray")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;to?a%=o:o%=a}a=abs(c*n[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),n=0;n":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n",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),n=0;n=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 28 Feb 2021 14:26:21 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") \nCopyright (c) 2018-").concat(t," 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:"Sun, 28 Feb 2021 14:26:21 +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,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/spec/lips.spec.js b/spec/lips.spec.js index 425dd71d..90f594af 100644 --- a/spec/lips.spec.js +++ b/spec/lips.spec.js @@ -17,124 +17,6 @@ var { var deps = lips.exec('(load "./lib/bootstrap.scm") (load "./examples/helpers.scm")'); -describe('tokenizer', function() { - it('should create tokens for simple list', function() { - expect(tokenize('(foo bar baz)')).toEqual(['(', 'foo', 'bar', 'baz', ')']); - }); - it('should create tokens for numbers string and regexes', function() { - expect(tokenize('(foo /( \\/)/g "bar baz" 10 1.1 10e2)')).toEqual([ - '(', 'foo', '/( \\/)/g', '"bar baz"', '10', '1.1', '10e2', ')' - ]); - }); - it('should create tokens for alists', function() { - expect(tokenize('((foo . 10) (bar . 20) (baz . 30))')).toEqual([ - '(', '(', 'foo', '.', '10', ')', '(', 'bar', '.', '20', ')', '(', - 'baz', '.', '30', ')', ')' - ]); - }); - it('should ignore comments', function() { - expect(tokenize('(foo bar baz); (baz quux)')).toEqual([ - '(', 'foo', 'bar', 'baz', ')' - ]); - }); - it('should handle semicolon in regexes and strings', function() { - expect(tokenize('(";()" /;;;/g baz); (baz quux)')).toEqual([ - '(', '";()"', '/;;;/g', 'baz', ')' - ]); - }); - it('should tokenize with data', function() { - var code = `(define-macro (defstruct name . fields) - "First Line." "word" 10 - "Second Line." "word" /regex/ - "Third Line." "word" - (let ((names (map (lambda (symbol) (gensym)) fields)) - (struct (gensym)) - (field-arg (gensym))) -`; - var output = [ - { col: 0, line: 0, token: '(', offset: 0 }, - { col: 1, line: 0, token: 'define-macro', offset: 1 }, - { col: 13, line: 0, token: ' ', offset: 13 }, - { col: 14, line: 0, token: '(', offset: 14 }, - { col: 15, line: 0, token: 'defstruct', offset: 15 }, - { col: 24, line: 0, token: ' ', offset: 24 }, - { col: 25, line: 0, token: 'name', offset: 25 }, - { col: 29, line: 0, token: ' ', offset: 29 }, - { col: 30, line: 0, token: '.', offset: 30 }, - { col: 31, line: 0, token: ' ', offset: 31 }, - { col: 32, line: 0, token: 'fields', offset: 32 }, - { col: 38, line: 0, token: ')', offset: 38 }, - { col: 39, line: 0, token: '\n', offset: 39 }, - { col: 0, line: 1, token: ' ', offset: 40 }, - { col: 2, line: 1, token: '"First Line."', offset: 42 }, - { col: 15, line: 1, token: ' ', offset: 55 }, - { col: 16, line: 1, token: '"word"', offset: 56 }, - { col: 22, line: 1, token: ' ', offset: 62 }, - { col: 23, line: 1, token: '10', offset: 63 }, - { col: 25, line: 1, token: '\n', offset: 65 }, - { col: 0, line: 2, token: ' ', offset: 66 }, - { col: 2, line: 2, token: '"Second Line."', offset: 68 }, - { col: 16, line: 2, token: ' ', offset: 82 }, - { col: 20, line: 2, token: '"word"', offset: 86 }, - { col: 26, line: 2, token: ' ', offset: 92 }, - { col: 27, line: 2, token: '/regex/', offset: 93 }, - { col: 34, line: 2, token: '\n', offset: 100 }, - { col: 0, line: 3, token: ' ', offset: 101 }, - { col: 2, line: 3, token: '"Third Line."', offset: 103 }, - { col: 15, line: 3, token: ' ', offset: 116 }, - { col: 20, line: 3, token: '"word"', offset: 121 }, - { col: 26, line: 3, token: '\n', offset: 127 }, - { col: 0, line: 4, token: ' ', offset: 128 }, - { col: 2, line: 4, token: '(', offset: 130 }, - { col: 3, line: 4, token: 'let', offset: 131 }, - { col: 6, line: 4, token: ' ', offset: 134 }, - { col: 7, line: 4, token: '(', offset: 135 }, - { col: 8, line: 4, token: '(', offset: 136 }, - { col: 9, line: 4, token: 'names', offset: 137 }, - { col: 14, line: 4, token: ' ', offset: 142 }, - { col: 15, line: 4, token: '(', offset: 143 }, - { col: 16, line: 4, token: 'map', offset: 144 }, - { col: 19, line: 4, token: ' ', offset: 147 }, - { col: 20, line: 4, token: '(', offset: 148 }, - { col: 21, line: 4, token: 'lambda', offset: 149 }, - { col: 27, line: 4, token: ' ', offset: 155 }, - { col: 28, line: 4, token: '(', offset: 156 }, - { col: 29, line: 4, token: 'symbol', offset: 157 }, - { col: 35, line: 4, token: ')', offset: 163 }, - { col: 36, line: 4, token: ' ', offset: 164 }, - { col: 37, line: 4, token: '(', offset: 165 }, - { col: 38, line: 4, token: 'gensym', offset: 166 }, - { col: 44, line: 4, token: ')', offset: 172 }, - { col: 45, line: 4, token: ')', offset: 173 }, - { col: 46, line: 4, token: ' ', offset: 174 }, - { col: 47, line: 4, token: 'fields', offset: 175 }, - { col: 53, line: 4, token: ')', offset: 181 }, - { col: 54, line: 4, token: ')', offset: 182 }, - { col: 55, line: 4, token: '\n', offset: 183 }, - { col: 0, line: 5, token: ' ', offset: 184 }, - { col: 8, line: 5, token: '(', offset: 192 }, - { col: 9, line: 5, token: 'struct', offset: 193 }, - { col: 15, line: 5, token: ' ', offset: 199 }, - { col: 16, line: 5, token: '(', offset: 200 }, - { col: 17, line: 5, token: 'gensym', offset: 201 }, - { col: 23, line: 5, token: ')', offset: 207 }, - { col: 24, line: 5, token: ')', offset: 208 }, - { col: 25, line: 5, token: '\n', offset: 209 }, - { col: 0, line: 6, token: ' ', offset: 210 }, - { col: 8, line: 6, token: '(', offset: 218 }, - { col: 9, line: 6, token: 'field-arg', offset: 219 }, - { col: 18, line: 6, token: ' ', offset: 228 }, - { col: 19, line: 6, token: '(', offset: 229 }, - { col: 20, line: 6, token: 'gensym', offset: 230 }, - { col: 26, line: 6, token: ')', offset: 236 }, - { col: 27, line: 6, token: ')', offset: 237 }, - { col: 28, line: 6, token: ')', offset: 238 }, - { col: 29, line: 6, token: '\n', offset: 239 } - ]; - expect(tokenize(code, true).slice(0, output.length)).toEqual(output); - }); -}); - function exec(string, env, dynamic_scope) { return evaluate(parse(tokenize(string))[0], { env, dynamic_scope }); } diff --git a/src/lips.js b/src/lips.js index 75bc85e0..9c875651 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1216,6 +1216,7 @@ [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], + [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], diff --git a/tests/parser.scm b/tests/parser.scm index f8174ff5..61f990aa 100644 --- a/tests/parser.scm +++ b/tests/parser.scm @@ -149,3 +149,41 @@ (match #/([^<]+)<\\/title>/) 1)")) (t.is (eval (. code 0)) "hello-world"))) + + +(test "tokenizer: should create tokens for simple list" + (lambda (t) + (t.is (lips.tokenize "(foo bar baz)") + #("(" "foo" "bar" "baz" ")")))) + +(test "tokenizer: should create tokens for numbers string and regexes" + (lambda (t) + (t.is (lips.tokenize "(foo #/( \\/)/g \"bar baz\" 10 1.1 10e2 + 10+10i +inf.0+inf.0i +nan.0+nan.0i 1/2+1/2i)") + #("(" "foo" "#/( \\/)/g" "\"bar baz\"" "10" "1.1" "10e2" + "10+10i" "+inf.0+inf.0i" "+nan.0+nan.0i" "1/2+1/2i" ")")))) + +(test "tokenizer: should create token for alist" + (lambda (t) + (t.is (lips.tokenize "((foo . 10) (bar . 20) (baz . 30))") + #("(" "(" "foo" "." "10" ")" "(" "bar" "." "20" ")" "(" + "baz" "." "30" ")" ")")))) + +(test "tokenizer: should ignore comments" + (lambda (t) + (let ((code "(foo bar baz); (baz quux)")) + (t.is (lips.tokenize code) + #("(" "foo" "bar" "baz" ")"))))) + +(test "tokenizer: should handle semicolon in regexes and strings" + (lambda (t) + (let ((code "(\";()\" #/;;;/g baz); (baz quux)")) + (t.is (lips.tokenize code) + #("(" "\";()\"" "#/;;;/g" "baz" ")"))))) + +(test "tokenizer: with meta data" + (lambda (t) + (let* ((fs (require "fs")) + (code (--> (fs.promises.readFile "./tests/stubs/macro.txt") + (toString)))) + (t.snapshot (lips.tokenize code true))))) diff --git a/tests/ports.scm b/tests/ports.scm index 7f0d92d7..0af12797 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -1,4 +1,4 @@ -(test "ports: scheme repr (output-string)" +(test "ports: scheme repr using output-string" (lambda (t) (define (repr x . rest) (let ((port (open-output-string)) diff --git a/tests/snapshots/test.js.md b/tests/snapshots/test.js.md index 1788b379..cbbb7a74 100644 --- a/tests/snapshots/test.js.md +++ b/tests/snapshots/test.js.md @@ -148,3 +148,1225 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 '<div data-foo="hello" id="foo"><button id="btn1">me</button><button id="btn2">me</button></div>' + +## parser: tokenizer + +> Snapshot 1 + + [ + { + col: 0, + line: 0, + offset: 0, + token: '(', + }, + { + col: 1, + line: 0, + offset: 1, + token: 'define-macro', + }, + { + col: 13, + line: 0, + offset: 13, + token: ' ', + }, + { + col: 14, + line: 0, + offset: 14, + token: '(', + }, + { + col: 15, + line: 0, + offset: 15, + token: 'defstruct', + }, + { + col: 24, + line: 0, + offset: 24, + token: ' ', + }, + { + col: 25, + line: 0, + offset: 25, + token: 'name', + }, + { + col: 29, + line: 0, + offset: 29, + token: ' ', + }, + { + col: 30, + line: 0, + offset: 30, + token: '.', + }, + { + col: 31, + line: 0, + offset: 31, + token: ' ', + }, + { + col: 32, + line: 0, + offset: 32, + token: 'fields', + }, + { + col: 38, + line: 0, + offset: 38, + token: ')', + }, + { + col: 39, + line: 0, + offset: 39, + token: `␊ + `, + }, + { + col: 0, + line: 1, + offset: 40, + token: ' ', + }, + { + col: 2, + line: 1, + offset: 42, + token: '"First Line."', + }, + { + col: 15, + line: 1, + offset: 55, + token: ' ', + }, + { + col: 16, + line: 1, + offset: 56, + token: '"word"', + }, + { + col: 22, + line: 1, + offset: 62, + token: ' ', + }, + { + col: 23, + line: 1, + offset: 63, + token: '10', + }, + { + col: 25, + line: 1, + offset: 65, + token: `␊ + `, + }, + { + col: 0, + line: 2, + offset: 66, + token: ' ', + }, + { + col: 2, + line: 2, + offset: 68, + token: '"Second Line."', + }, + { + col: 16, + line: 2, + offset: 82, + token: ' ', + }, + { + col: 20, + line: 2, + offset: 86, + token: '"word"', + }, + { + col: 26, + line: 2, + offset: 92, + token: ' ', + }, + { + col: 27, + line: 2, + offset: 93, + token: '#/regex/', + }, + { + col: 35, + line: 2, + offset: 101, + token: `␊ + `, + }, + { + col: 0, + line: 3, + offset: 102, + token: ' ', + }, + { + col: 2, + line: 3, + offset: 104, + token: '"Third Line."', + }, + { + col: 15, + line: 3, + offset: 117, + token: ' ', + }, + { + col: 20, + line: 3, + offset: 122, + token: '"word"', + }, + { + col: 26, + line: 3, + offset: 128, + token: `␊ + `, + }, + { + col: 0, + line: 4, + offset: 129, + token: ' ', + }, + { + col: 2, + line: 4, + offset: 131, + token: '10', + }, + { + col: 4, + line: 4, + offset: 133, + token: ' ', + }, + { + col: 5, + line: 4, + offset: 134, + token: '10+10i', + }, + { + col: 11, + line: 4, + offset: 140, + token: ' ', + }, + { + col: 12, + line: 4, + offset: 141, + token: '+inf.0', + }, + { + col: 18, + line: 4, + offset: 147, + token: ' ', + }, + { + col: 19, + line: 4, + offset: 148, + token: '+inf.0+inf.0i', + }, + { + col: 32, + line: 4, + offset: 161, + token: ' ', + }, + { + col: 33, + line: 4, + offset: 162, + token: '+nan.0', + }, + { + col: 39, + line: 4, + offset: 168, + token: ' ', + }, + { + col: 40, + line: 4, + offset: 169, + token: '+nan.0+nan.0i', + }, + { + col: 53, + line: 4, + offset: 182, + token: `␊ + `, + }, + { + col: 0, + line: 5, + offset: 183, + token: ' ', + }, + { + col: 2, + line: 5, + offset: 185, + token: '1/2+1/2i', + }, + { + col: 10, + line: 5, + offset: 193, + token: ' ', + }, + { + col: 11, + line: 5, + offset: 194, + token: '10.10+1/2i', + }, + { + col: 21, + line: 5, + offset: 204, + token: ' ', + }, + { + col: 22, + line: 5, + offset: 205, + token: '1/2+10.0i', + }, + { + col: 31, + line: 5, + offset: 214, + token: `␊ + `, + }, + { + col: 0, + line: 6, + offset: 215, + token: ' ', + }, + { + col: 2, + line: 6, + offset: 217, + token: '(', + }, + { + col: 3, + line: 6, + offset: 218, + token: 'let', + }, + { + col: 6, + line: 6, + offset: 221, + token: ' ', + }, + { + col: 7, + line: 6, + offset: 222, + token: '(', + }, + { + col: 8, + line: 6, + offset: 223, + token: '(', + }, + { + col: 9, + line: 6, + offset: 224, + token: 'names', + }, + { + col: 14, + line: 6, + offset: 229, + token: ' ', + }, + { + col: 15, + line: 6, + offset: 230, + token: '(', + }, + { + col: 16, + line: 6, + offset: 231, + token: 'map', + }, + { + col: 19, + line: 6, + offset: 234, + token: ' ', + }, + { + col: 20, + line: 6, + offset: 235, + token: '(', + }, + { + col: 21, + line: 6, + offset: 236, + token: 'lambda', + }, + { + col: 27, + line: 6, + offset: 242, + token: ' ', + }, + { + col: 28, + line: 6, + offset: 243, + token: '(', + }, + { + col: 29, + line: 6, + offset: 244, + token: 'symbol', + }, + { + col: 35, + line: 6, + offset: 250, + token: ')', + }, + { + col: 36, + line: 6, + offset: 251, + token: ' ', + }, + { + col: 37, + line: 6, + offset: 252, + token: '(', + }, + { + col: 38, + line: 6, + offset: 253, + token: 'gensym', + }, + { + col: 44, + line: 6, + offset: 259, + token: ')', + }, + { + col: 45, + line: 6, + offset: 260, + token: ')', + }, + { + col: 46, + line: 6, + offset: 261, + token: ' ', + }, + { + col: 47, + line: 6, + offset: 262, + token: 'fields', + }, + { + col: 53, + line: 6, + offset: 268, + token: ')', + }, + { + col: 54, + line: 6, + offset: 269, + token: ')', + }, + { + col: 55, + line: 6, + offset: 270, + token: `␊ + `, + }, + { + col: 0, + line: 7, + offset: 271, + token: ' ', + }, + { + col: 8, + line: 7, + offset: 279, + token: '(', + }, + { + col: 9, + line: 7, + offset: 280, + token: 'struct', + }, + { + col: 15, + line: 7, + offset: 286, + token: ' ', + }, + { + col: 16, + line: 7, + offset: 287, + token: '(', + }, + { + col: 17, + line: 7, + offset: 288, + token: 'gensym', + }, + { + col: 23, + line: 7, + offset: 294, + token: ')', + }, + { + col: 24, + line: 7, + offset: 295, + token: ')', + }, + { + col: 25, + line: 7, + offset: 296, + token: `␊ + `, + }, + { + col: 0, + line: 8, + offset: 297, + token: ' ', + }, + { + col: 8, + line: 8, + offset: 305, + token: '(', + }, + { + col: 9, + line: 8, + offset: 306, + token: 'field-arg', + }, + { + col: 18, + line: 8, + offset: 315, + token: ' ', + }, + { + col: 19, + line: 8, + offset: 316, + token: '(', + }, + { + col: 20, + line: 8, + offset: 317, + token: 'gensym', + }, + { + col: 26, + line: 8, + offset: 323, + token: ')', + }, + { + col: 27, + line: 8, + offset: 324, + token: ')', + }, + { + col: 28, + line: 8, + offset: 325, + token: ')', + }, + { + col: 29, + line: 8, + offset: 326, + token: `␊ + `, + }, + { + col: 0, + line: 9, + offset: 327, + token: `␊ + `, + }, + ] + +## tokenizer: with meta data + +> Snapshot 1 + + [ + { + col: 0, + line: 0, + offset: 0, + token: '(', + }, + { + col: 1, + line: 0, + offset: 1, + token: 'define-macro', + }, + { + col: 13, + line: 0, + offset: 13, + token: ' ', + }, + { + col: 14, + line: 0, + offset: 14, + token: '(', + }, + { + col: 15, + line: 0, + offset: 15, + token: 'defstruct', + }, + { + col: 24, + line: 0, + offset: 24, + token: ' ', + }, + { + col: 25, + line: 0, + offset: 25, + token: 'name', + }, + { + col: 29, + line: 0, + offset: 29, + token: ' ', + }, + { + col: 30, + line: 0, + offset: 30, + token: '.', + }, + { + col: 31, + line: 0, + offset: 31, + token: ' ', + }, + { + col: 32, + line: 0, + offset: 32, + token: 'fields', + }, + { + col: 38, + line: 0, + offset: 38, + token: ')', + }, + { + col: 39, + line: 0, + offset: 39, + token: `␊ + `, + }, + { + col: 0, + line: 1, + offset: 40, + token: ' ', + }, + { + col: 2, + line: 1, + offset: 42, + token: '"First Line."', + }, + { + col: 15, + line: 1, + offset: 55, + token: ' ', + }, + { + col: 16, + line: 1, + offset: 56, + token: '"word"', + }, + { + col: 22, + line: 1, + offset: 62, + token: ' ', + }, + { + col: 23, + line: 1, + offset: 63, + token: '10', + }, + { + col: 25, + line: 1, + offset: 65, + token: `␊ + `, + }, + { + col: 0, + line: 2, + offset: 66, + token: ' ', + }, + { + col: 2, + line: 2, + offset: 68, + token: '"Second Line."', + }, + { + col: 16, + line: 2, + offset: 82, + token: ' ', + }, + { + col: 20, + line: 2, + offset: 86, + token: '"word"', + }, + { + col: 26, + line: 2, + offset: 92, + token: ' ', + }, + { + col: 27, + line: 2, + offset: 93, + token: '#/regex/', + }, + { + col: 35, + line: 2, + offset: 101, + token: `␊ + `, + }, + { + col: 0, + line: 3, + offset: 102, + token: ' ', + }, + { + col: 2, + line: 3, + offset: 104, + token: '"Third Line."', + }, + { + col: 15, + line: 3, + offset: 117, + token: ' ', + }, + { + col: 20, + line: 3, + offset: 122, + token: '"word"', + }, + { + col: 26, + line: 3, + offset: 128, + token: `␊ + `, + }, + { + col: 0, + line: 4, + offset: 129, + token: ' ', + }, + { + col: 2, + line: 4, + offset: 131, + token: '10', + }, + { + col: 4, + line: 4, + offset: 133, + token: ' ', + }, + { + col: 5, + line: 4, + offset: 134, + token: '10+10i', + }, + { + col: 11, + line: 4, + offset: 140, + token: ' ', + }, + { + col: 12, + line: 4, + offset: 141, + token: '+inf.0', + }, + { + col: 18, + line: 4, + offset: 147, + token: ' ', + }, + { + col: 19, + line: 4, + offset: 148, + token: '+inf.0+inf.0i', + }, + { + col: 32, + line: 4, + offset: 161, + token: ' ', + }, + { + col: 33, + line: 4, + offset: 162, + token: '+nan.0', + }, + { + col: 39, + line: 4, + offset: 168, + token: ' ', + }, + { + col: 40, + line: 4, + offset: 169, + token: '+nan.0+nan.0i', + }, + { + col: 53, + line: 4, + offset: 182, + token: `␊ + `, + }, + { + col: 0, + line: 5, + offset: 183, + token: ' ', + }, + { + col: 2, + line: 5, + offset: 185, + token: '1/2+1/2i', + }, + { + col: 10, + line: 5, + offset: 193, + token: ' ', + }, + { + col: 11, + line: 5, + offset: 194, + token: '10.10+1/2i', + }, + { + col: 21, + line: 5, + offset: 204, + token: ' ', + }, + { + col: 22, + line: 5, + offset: 205, + token: '1/2+10.0i', + }, + { + col: 31, + line: 5, + offset: 214, + token: `␊ + `, + }, + { + col: 0, + line: 6, + offset: 215, + token: ' ', + }, + { + col: 2, + line: 6, + offset: 217, + token: '(', + }, + { + col: 3, + line: 6, + offset: 218, + token: 'let', + }, + { + col: 6, + line: 6, + offset: 221, + token: ' ', + }, + { + col: 7, + line: 6, + offset: 222, + token: '(', + }, + { + col: 8, + line: 6, + offset: 223, + token: '(', + }, + { + col: 9, + line: 6, + offset: 224, + token: 'names', + }, + { + col: 14, + line: 6, + offset: 229, + token: ' ', + }, + { + col: 15, + line: 6, + offset: 230, + token: '(', + }, + { + col: 16, + line: 6, + offset: 231, + token: 'map', + }, + { + col: 19, + line: 6, + offset: 234, + token: ' ', + }, + { + col: 20, + line: 6, + offset: 235, + token: '(', + }, + { + col: 21, + line: 6, + offset: 236, + token: 'lambda', + }, + { + col: 27, + line: 6, + offset: 242, + token: ' ', + }, + { + col: 28, + line: 6, + offset: 243, + token: '(', + }, + { + col: 29, + line: 6, + offset: 244, + token: 'symbol', + }, + { + col: 35, + line: 6, + offset: 250, + token: ')', + }, + { + col: 36, + line: 6, + offset: 251, + token: ' ', + }, + { + col: 37, + line: 6, + offset: 252, + token: '(', + }, + { + col: 38, + line: 6, + offset: 253, + token: 'gensym', + }, + { + col: 44, + line: 6, + offset: 259, + token: ')', + }, + { + col: 45, + line: 6, + offset: 260, + token: ')', + }, + { + col: 46, + line: 6, + offset: 261, + token: ' ', + }, + { + col: 47, + line: 6, + offset: 262, + token: 'fields', + }, + { + col: 53, + line: 6, + offset: 268, + token: ')', + }, + { + col: 54, + line: 6, + offset: 269, + token: ')', + }, + { + col: 55, + line: 6, + offset: 270, + token: `␊ + `, + }, + { + col: 0, + line: 7, + offset: 271, + token: ' ', + }, + { + col: 8, + line: 7, + offset: 279, + token: '(', + }, + { + col: 9, + line: 7, + offset: 280, + token: 'struct', + }, + { + col: 15, + line: 7, + offset: 286, + token: ' ', + }, + { + col: 16, + line: 7, + offset: 287, + token: '(', + }, + { + col: 17, + line: 7, + offset: 288, + token: 'gensym', + }, + { + col: 23, + line: 7, + offset: 294, + token: ')', + }, + { + col: 24, + line: 7, + offset: 295, + token: ')', + }, + { + col: 25, + line: 7, + offset: 296, + token: `␊ + `, + }, + { + col: 0, + line: 8, + offset: 297, + token: ' ', + }, + { + col: 8, + line: 8, + offset: 305, + token: '(', + }, + { + col: 9, + line: 8, + offset: 306, + token: 'field-arg', + }, + { + col: 18, + line: 8, + offset: 315, + token: ' ', + }, + { + col: 19, + line: 8, + offset: 316, + token: '(', + }, + { + col: 20, + line: 8, + offset: 317, + token: 'gensym', + }, + { + col: 26, + line: 8, + offset: 323, + token: ')', + }, + { + col: 27, + line: 8, + offset: 324, + token: ')', + }, + { + col: 28, + line: 8, + offset: 325, + token: ')', + }, + { + col: 29, + line: 8, + offset: 326, + token: `␊ + `, + }, + { + col: 0, + line: 9, + offset: 327, + token: `␊ + `, + }, + ] diff --git a/tests/snapshots/test.js.snap b/tests/snapshots/test.js.snap index 06ad58bd1a23260ab1793e70377c930a174cccac..efa089f0b6743bbf44524505e4ac24df9b233280 100644 GIT binary patch literal 18407 zcmV)GK)%00RzV<BZeeh9Xm4~Nb}|YA0OMVpy0Dji#Zs(**CEw~jvtE%00000000B+ zoe8vNRdwgTS49;w1q#T_qnN5J3huq<+;i>)3Y2+J5l|FCutqFXRB2IasT~!Qs4)l* zZ5(<ft;QrI(Ja%>A(1wN(ZnVp8tfzvojAoQj)_KNcmIF?`ykZ4@O{O5(rfivU*X16 z@7;6Hx##S&hyULDaO=!ywBKmkkuQ1ww?2F6$A0|kZ$J4J?S~K25B29AqO-OhcG0i? z`J!cy-1l!j`K(*tb>xhH`W?}hMcZEbnSFje9J%=e8-9Dk^~)Cdrzg&Ibd~4_*B}3; z$K7!4-@o${9}btl?Vb-V@=w1$M>j1RjrN$m^fiyT^@!p{=l=V5uDR&1FInoJ-abcP zn4{Un9X)4`-ZV$=6D|9j|9xe9!F4;HG`j81dse+>&&B@f*XHQ7Jv#bj(KFg-ed@pb z&A-ij?5@StmOYRBgBkzyOQKi)`lsIUyw7~}?ANSmZ~Mr8PyE7+e|o@@(ddzPpY)sG zyKCbMpZ}wG?zrS1kNCw!{^`+k^oHk*MsGj-r8k^;(yHS&-E`_57ku)}ugv(Ti?)wO zYp&b(RhQiK)~DTeLca8nZ`^qEjDPz5J4T~V-+AU`ci;2cor}&t<)Y7AcFF5z{L?Ql znHen}?dg@DSu#3k(Hll9wrt!nyJE%8*|J!<a-Z4R6`MEBu6W_b?c2_t-O1nivtr%G z8#Zs9`-}d%Ve?JT-m>-uv&(sI`O5$J#nz3_-?Dk@#+4I0Zr!$H_CY(ZTzUUF&YbNj zZr-tR`(U2D=Dx|^H)!|h>RCNIc-cvV?|t_6&0BYL-+Etr*FMMJ+h;dBEPDB9#rkbq zH>k^|ZQB?Kx_5T|*@|^*x6iIy`@;Js-CwHvt<}!^Ez)p_yBFSX8F{_lKKSw%PMFjD zXYwGg`HzY0GLMs2Y}mL-{kjKM?7ZJA-EEcjZD+sJ>hYbH@7%d_`Ga&l?cT2Lxn=E* z>o%+%zTrVSpSydVJ^pUJ@bFz<xcR0Xv*m0x8+wl|yZ>X_sNM?R^n$HB*6v)r{kdB< z-ZZ<yoVeopx%1k+bTDv!;7(na&6`&4)=RGLy=2Xrv+nJ;c2<9xT{qXew@@qA!g*(E zLDt@X=~kSjpR8LsVAaRYef{cgG!}tTh97YMDc^t6yT0zo6)U<m-e<Po_>TwokYKz% z?{bVcZ>h^BmQ7itA~r>nQybc*sGG9QZH`sWRcf0$)n!=}btv1A^mxui%2h~ZS;xAq zW7Wp2U#3)~vdMLwQVeyBIaMh)v8l>BSNd(0)w2n)ibYklrT!giyD<ho5Ml~r4p zg<cklP`4r0MWgYG*ao$$Rujlgku|4A?}$|uV$jn~N=;qFN-v3ZPGzcE4Vu~<+9HLb zYKpSZOKN=~!|M%tb*ZlkA@jdVA5>_LsnKtXoQk@P`rxK*QfyNlb8IzW&`UHwjg+)V zO%wH#(1u3SD(aeP)`jLAQd@;euPyY^`lB_{0%?ImtG~CcR<zY4O%-#ig~>(Kht$b4 zO<G7TMD2B~`N%SdCbuzEE$b25n3}Sw^lp7~4zbaU^=Q(E>;2liQlFV~Y+9{PC@ZZa zztWay$FjDp${Io6r6np0?Ov^=XbZlh&W$D<k`}e9%cKR@+ZwHf7(?9AYCffwxvIqs zTBfqnde%uZNa6!6R1<U2wx#B+e>brxVp#-MB5A+96WV(%vbIz#rADdA=zUt{qNubW z+JCW#7ETk<l54~=XlatBFUARcxb|O*Q)-8TI59OEyeX5|rLD>s)LBfb#jX9O#0<5B zp$>js6vMV+-z@%Yt3sQ`-WF9Qo)e=MO;d=;a;Ys6r|_woY{|~1QZH7kuC%b)Lh*W& zBeT%UqrSLg>ovbx->YTNH)icXBj&02!)Ijmj{)Y>$<krc&Nd+gmcG><F>SqClW25C z)Thxg(UH=k=*4U~Y!)gV8#Y<Yt}c<q&?akwV*jiy)MC~8WHut`4W&p6p%1O}x=?G! zHI_bBldJW=TFj-Di&`=r{@C!c$Vt>p8~V2ToqkZ1dSBEUz%rV$SgX~RNnU8_3hiB} zv>*}(G3gt$Cz+4X2`ROmVq%S>2bq|-DaBaB%sG@|J`I&a)>ah(p3IewjpmVZsh4J* zF?|z9rfs#2b*i)^;vP+2e5OaVo!YseW&t0<V3oE>JgCJIqw7f2fz8%=j#?ufvbNBs zw|s9Buj$-3+AIB3?-VEMWA!DWK>p}F#H7!yy=6fwFGdTnq~w}TNrubd96iw_t)=)` zyAXBUw74ZKDSm0P_^Q&JkV6tfS+gsvKuZg02_m)=M|IsLb+vzNSn@j89CN)wbJk+& zBO7Fhwn(Q*zd&e+t1CD{VoE1O^OA51I)9~pAkkVNro}YL@=1cRDqF9Kc2&|xTPvoO zxYsch1Jo_cFW!|1F7$eBg1$kYAACkC9b0XCqbWBMxVc2MNt$U!661PCYo&LI?V3sg zR+2;us72LIiq|yvtlzbgoVA$PQw(~!mau8yM)j5GZG2!0i97Yxc$Q5qr>)==bJA+< znFIvus)HeZ(E&q@<f3W$W>!3LV69IyH_5!3iB;$^SWw&{4J9ch7L>fJkmPNGiFKC6 z!`f-BkERs#lU6!S99SZ&LWIvGe$ZIfjp8OvO`HlBXg8Rjgn-^DB_|HlVbQ~dCayuH zeZ<@uB_!<_B~@CBoJP7WNge2b6qSyq7+qUdi-W2t5uslOx@xvs5q+sf<VOVxKu;zM zx2QGKoH<KTy|o&eQ>m|%?$Z})4*EE@Ufh#8dD?q4fH*}OL#vlqSJW2^(E2B6lPu0C zGD1c2R<ji^R-A%}L<+o+Rbbo2cv`27t}-)=S2FA!5v;N(ba?aweFqxG2dwVoyOy-T zLXZv-hl$(8;izI}SRyeQQJhpW6RmPxRY+6>upZS!3s_Lw0k22}YCl8eqpk(4ID>)F z3hW1|G_)QHNHShhK!R36Myrs}zurR01&jn89X%{jA=#DbA-$^+nY=bsYoITYfRIj0 z=tn85h;GrsWNDB}ORo1t1euskU#4TBcSdx!_DB*14Uf_**g(z6yDS~9A4kjzUMS8L zYiJX+;F61y!5TwiPamVhEuB(hN@=NeE{YO+LNC+~O7gZo=I9~~%~8r`BB^vOoK{Fe z385*eS+jF3Cqw$IM0AQRB!&vk3~Lfm;}N5wV#%>SN{);KhB!}>8%-6EPMVN*Q~w~p zIZfIdPJA-wq9es7I!}7NI89OzQ>Mg(k$BNwHTsO8<EyO~14^!FS@kWI7Fq03NNQ_> zWvmgQVlMS$H7pDp*rwLv>kD;qCG?9%CM@cy?lw)^iE)e6#wIJVBeGO!14kpE5LnvG z60;Cp6QvfVcLREhU&wx{;Y&0`!lV)(*6^@|m9{ZUi0T+%6-f7sNA&KhK*rXZpiB-- zH)-k;UN2b;eNAb*N$ekxpJFqajci?{YXui$;Br`)m3UEGkP)~sL=1BTxp<>ujr2Sw zl$Ze?#-_yD(*}#ZrTL{!CBQUgac72q6YGjb5;rs)G0jEiOjezJ0cpdC=+<}Y%TQio zUF4gdm2|^?i6~;26ZVl2E>_Uj>cCYfO%7OOX4ZuT?tm77(}mqGu^{;?=_ek*&es}< zPvLfp6I=~G7nX-7HEpeZ?u4XFikbrvI8GUt025#Agt-sj%ZfxAmtqI~R0a&@V`WoA z!chjSB%wBi+3K6LDKet0W&)<J4j0m2av`A&u`*B-;yN+34F?Hd_1A|;k7$c+qG{F= zM{4Uw2>Mo?koc+7)LI^-g(SSz4lyGJmZ2g8P%DEJ(RRwL7yo4zHex$z8a16Yex-$D z_e*wDYotY}km{1nS`Hm*BwFVt6fmv$$JUA#%F04oCE$?Mn0I_Irk!MBK+nUS(IP~g zS7VCmcak2du&T$*5&twy2QMbW3z|O$0y;&%lvS$_4YgNN+pfjcx67W%$U&>wgw(-5 z!SHGjS+HinMv*aEbp8=L8Tdy!L<YJn!y3~|jP7HBt*^5R7h9`aOqcu`TT;d)I;O#J z&#+D-p_Ac!9e0g@rRzf~<5Y~RqtjwVv=|Q=DJ!8^;ztIUI&##dt0mlIqv*U~TIjd9 zOf8aDMs<UiQDJ0azlndPj%~pp-~FMP!>0YyIgEI-@QBnzY1gN~WY(```r%(|%cPKS zoD+tBz?RZ+DG;9OfWkl`YY%0lOS$N^ScGCdyw;W{WPu`n3Ogqiwvqgg!iy=P%5leP z;dEAIXCz1gNA$Mj5^prSX{R+OeXSN>rl5|ict>I^p)sZM8@YoO(iH1QJS#RS(bl-P z94sAI*;ledq>gc?#4m}HTKj+&s3RNz@PS$jj6|!jU(5z2XGG(RKP95YhFS|9VpK5T zLW`d$RUrd}z0tOanZz7gJ*|yKFp8md&<nLI1s<uEy_1tLg%|_@g}Z_nC~&aEjnbwC zo}!*W$W&NhIvoWH14~wKkgbFDi=))yp6e7;iSsX|D~q>5yy~FB$c>E!t(csBO)ci` zSW3L=&|)T_9g+F9P0xUe2^NW1u>m9?AdDNlH(Br)pjgSts$awNikibKk49!DUZEva z#!%Hr;1GCE;=ls)8%tEeiPb{8N~^1x@ZKZpxP)O#@PYscA&G!brdjcOjBic61Vhl0 zH8>I+Oyfcof<!vDK<8jAN#b(uEA+P(6(<O8z{!vX)}lm95%mBmNT_|u4{->LUU9UL zgIWPSSfMa%=mPC%fiq0Z0p(<gS0j5B>_qE3a8-Tg^{qO#nQzu02{o=mz|OZmHxbtz zL<m0Up4U!R7(oexA#nsM^p5c&sTnP-<PYvdwu7mO<5|c^l!R_j*dS#I;Hm~Rs*wf& zQ(7@h9~}oVIA)+^wq+WM8oShjwZ+TRk&qC<>N8T(@GUwj_$uNad(HaH8gD1qo5m*8 z+yP}OtT}OfKsdL^Hk=^zMnK<Vxr^7twla)r8~9jk(!6xXjM4P;PEAawP-jQ{B8JCG z)IuAx0dB(r!9A6fXW#Jwvfhn~z@8AJO49h8N^xQva*#BCEm#dgqJ7k7>C{J7UTYqK zKr&Jk6BZ-0K%j{GWEM%{%LFP=(kL3MP4p{I@v(-WwEsF*C{Qu5Oo;+)E92d2>#z?q z{t}WGV>aQ*YSm>aYSQ?|SU3fq8q5RAB4?pRWz;rdD|4viSi~2M00NbCK+0I?fTud3 z=o45OV-}F80X>nR#pRLi!<-T4>Vr!*Q0EpGS$ocm^&ZK#(l&iCn8x`j`HT`?&@QtJ zn8=co+T#QoCJRQBuP~IQ_c^pE$OQH&2?&V5@kh&oBcZ$X6*|ipdl;OOEl3UC4JyZu zX$}Zky(E{0jF6=^d1}l7fDnu&Ualj7`j9mun_P~g&b*;c4t<GHD=}`9OY<qb4Xmm` z1c^~>d97x^YtjgMjtxi#i<yCrD2fB_s1bdEy%le2=_88@l!HQ+IB$R?B<a9sJM9Xr zVs^<!#U%f5##q1#Q!ufy5&$v+wEY#Zp>zrO1qPGxPkn8H^wFwW;Ynz4;KY!csf=Pg z40Y7DaeP4q^+!Kx@${ubwZ=F(1)c#mvfd;?4qzaGmw`G;vn(K;7KkGR5*W~QC3cC< zt2O`+1$(E3OQm+AKeGh1Xs~O<N$!D3D@B~J0)fi4{Bu}^4wH12et_kaJO2S|i0!U< z44^?HmdGMlS^pA)X<5+@e5W=l;xeLXO5mkXF-7^angr-{fwzO%lD&}{$$$uYBG~^0 z{^lQcLVVKL4&ymFx!Ac_Er9d3b@i$SmkIHTW<=D90r;^vphWUkbmW|~J#ek|IKd+l z9Sum6%q;+&3_pv<^lCAHg)^=Rh=YVWhO7QnfgfYL;K9|#dJ6*&m^?ZNQak`$`1aa7 z@n3_0(fLzfEEfz~PzHpD1g4ghpa!O@@d2I#H7JnVSVbi&3`f8~CFmK}5J<jW15hMp z)vWbfge4H7{c-Uw5D?223C~D&VfpGfVsoO{^sxnT4)MKqhRB6%UDQmAcEN0Dfs9b& zb{(;YSt$4$<jMX94g|21oFERBzQDjh#JB<MPK^y!u^Xn3P9gr7)}XZai1ifNnHEE` z^R#6%NNmWcM`k5>2lJr;caEG^eN%&ph6!Vf7(NG=DG551z^vfj71nveXe_akq-nIo zHF5+Tx&~m5glIHT@c{5%o>PcuA9M_!DCT%Zx?+WREl}zacPoI6RG0+~o>kj;6*<mC zjtbaYGnHh*C`>4x8VOY4I!j#PbUECBLtslTaR79ZBai_w3(y%ZyD?0yyST8xXTsSe z288X5SFKLQDhlF9NE_fh@el5ZjcEj|6s)WUja*`;i~BUHe9YS5I6Dy>*Qhl*mY_r# zt_rag;(9F_*oYqLNn4B~Z>+X5PR}_GXmT7zV3ZaW9PrKoB{U=8I&ghZmI$_}bCE$D zI%pqV7dciDQHD&-RunidmD$`nQir?5-o)OM)6l>`gjZzRVdd4@u7r&)35yX-a0g>l z@=gMw0tb>nDSf)7s>QvsfYFu(9ksrZFd%#Z@PJq%;zXdzs5`TSt<i=cQ!ODk4k6(e zge8X?KCK)&$Tmd4IZDjF1juVnWFPRaYvYhMjm7OX@E_`>LEn}5MA}<iIR?Tn<{V<T z)<AC+UK^->ix*U3)t3eX@pB8@Hq>5?KuMhgTo^|2Apo{PkObl|-K!!I4nR1^Kmt1< zAH)_5ZmXfYj0_H7ocbz&7rbPEXEeR0-!u*(vabbDe#E-QgTpA(S&G)mu`~uA5X2Q` z5U_V^R~{HkldcRWh*N+m3#M5Zk#_(`E7xM5z&Nd~#)7~ITmncWj|z8;kT0Q%h)5RO zwKxiyASdHs*JErEITO2R&;%x(@mlezV0r>FI`B0<8ZZFiSBxAY1({V6D<%xJ3fvwj zLkC-|T{@tKDAKxt5@%pVgSG`hof_W-qrbFXiygEsSxmSPUI7>r^MgBcNDCZRqP<17 zPyl<7z~qF14zxfFavKXz1dcFhP++QS)k?w$0S88sFC!Mg<bfYbbOjgz(V_y&vceBQ zT@%z0e<PA=Pzm%`#5+#GU_x*Z0ep}*N>+mpYk4tkDm<eC01SS~{tJe!J`MXuAEvP! z5yM$)abpp|6;TIdw7xY4+kzld$Yj7Ly*IKzr45CqgYH_(ZXg{AMg2TrDV6qLG2En2 z2*;;62!|L(2~R|V!(uNqH@wh-ugi|cy=FF*fjS9*fH?{13L?-Nx*^P1VfC^=Vs!(L zz$!&ya0KTy`^Bg!B2G9gq4R|ZI%pjtHmhL)y#?je+AAWYoQP);LKl}|1Z2`BlHp}= zOzm}RFh&dQSV~Dyyv6GVsOB`FggD74D$K{+#i$K%N5Vf2Hex~4xP|t)DuU<4eF+NT zum=Fh8Z6sd2RINLu|;CFm7#X5k<!RpO=K8kJ)>6%126%kAHk!#HWpGj+W`-g0HziS zo0tDp7z{1^RbXdmZ*Xlgkwwfhv<(RrHD)ay5<-g%0v!OoMhoF&4?^MMKh77PBBA)~ zI0OE13AButt9KKkBq|UI9hB@w%a@5qB@Z$mM&3#SXh38q;-5NGH6d0_v}_H!b_N&L zSjon6paWah8dHlnVj5Fx3+^5b^bsg%@FctO5Ezjt1dr++Ezx~V5(ga(B1wq7FCkE} z!UiA_IiT8bsf4&rx#3x&m~!y=7I7y~GS6#|D`PS>Ar5H~lvOMoT#H!VMDnXn{}Dw2 z91U2hl6hGDEr>s6If|k-Oo9>3RwDEqCm>is#2W+!v!D1rh6J`Wo<^AaAKroUI}kfg zH9$H624TLJ2Jyg}NCMK4Abg3bQIM6<nzJQ7z^GuT#@Yw#l;|0r6RL$2f(!x$5TT_e zeJBEX1=a<$lYmczOH=KDCDJ*eT@3u<=NtYbh8*nJU=4vOMa(_=hR!SoO^;TCT05ko z6cy2G5+aC8fcf#6*%>xi>jaX45(!H<2q_6gNFHcG=a`He!aFr+hRoSue~Y*%yM~F^ zqI+1E7KsqZD<Ujzb0(pk6B{JiR@*rvyoK1-?jUMmcdY%21d)nG!+OGchjH*q@Y1{J zsJ-8W%?w5)tB-?Ak`LmoMUG)?5wjsPBcV|7?U7zJE{Tqv{@=k78Ke~!2jL1(i-f6L zwoWx@I%^9MiNq*^^&}Kw7y?CBrJ)&+SIcA)RIu2HC?MW45hS2aCK4Uy2xJ+sCHlhJ zz!P?hrkRW-CdYLcUxNUh!Pw||kY0f1688~Pi-;Z897!%1o7g}EBH<Bi7qL?XJ69x` z;1KF4)Pzql;PBZ9sFGG-Z`Dx>+;+0jKvEN2iERjAB^9h4LRqv}92~z;SfAp<R2^nu zC*H|i4X$3`AQ2^OiI`(jVH4@o#Wb8s@HOPWHW@#I(2QkrYon=djEXr0512nCdwWhu z5T|2fM^11sw1q^q8>-0@+$)Szv6HwA8OsCx+LFN0lE;Ea0EXY7y91DR2_RSzc9u0L z0|4B?nPy-%hCD%lw7mgs=QybNsKuqgC1yPlg#~Vm_73r#oK45*_}}P1OkdldfaDGd z1@sdUJ5pdOPBn)TDTId}Q9Lb(V6>wfuy_oeV-69!!*)iPIC@-j0L6*gXABlHw20G1 z&Yu_uNDC`FkiLk8M6Q)}mGkYax4@~{J3w0ET*zi1K=nm;I;V&fE_5BqNq|hCk`b(- z#u!Yg3s5zdY&GeVEh@W$VOspiio-)LVIV#zBPS7ACQ}F-kJKNW2uF$m(|}pQ83<=1 ztP7_kB1wo*gE#>u5~GMn7c3jB%H;GsZFaKbW{e*5BO(1snj#ql*apkacsr_rT!-2z z4@9UOkmo=VASoSiAr4Vtry-pRA~c;NrXwDa>Er={?_%D`=C2)jW8$P>kxZDd;Vo~l z6?JS$tOJ}t=!2vo#mS-}(FZGvq)S{8a2m{fa?x<kNm)qFvLFgjd(pwPv7u6@TR=7{ zGOa+jOH>EG8_`uVJM<8kc7ryAr*J1bLCx7irv><ytPjo>;53jxB+&t29?Y`_zr~l8 zPHu=iXuIvQ5j{q0ITgt%NF)s=yqzfaw_<kY8%C{E21$RU(#VoQeCh%0cby3{91vGT zmX_p50@-3hf|CN;5*uy!8OM?MG5&Oeo^D8gDD1U^l$XY$0$B+7ml%>DyM#28^F_#F zz)c}&rirwuQu39G%DIvFeS~bmZUf+=L`6YTiNplHj~>>~oS92>080-^);N-@Ke$;^ ztp(ly8H9xLrSrgINS-s)sS}?KJ0rWnsL7Kgt-$8{oaaI6ASMxh8PFfm$<W2m%GPFJ zi^o_w?SkR4Ey#S7PC+?1-JvAn#9BB|0R)GoM+#Dl#iOH_IA&^y4RB{m62Ul&TJ-|8 zMCO$wPQ<50*&`;TD3DSlz|^GwR1Wi3g%hD{s5|?C%u}5^Vw(6Y0roW1WT>EW)<i)5 z67t0jCU$Ep%*v-bw0LoZpIU>+nI9qFH7iniZI=RT5?vuRvUb=Bvj(gqfM=kr#6p;6 z<ORze!6DN8WTUl}0ctEoTtN1MoGI)pWE|;c4S`Rx4p<m{4_t(2pIXCd1+I2-l!+)c zVouVEC>+uQbhB~xsL^$aa?OUYZwBZf4XiSHmTFHI>%DQr-Kl>hlh@>5VmOdjYM;1; zWm`fP<SVyM3&%19j?IJ>5P^W3SWW=2xGrQ&B#b4J+{HKgr^QkRH?i=Br_q9#+y&kT z>1E<}3%Uk4)yN#F4Gtn3y2&7OV7OpqV&>AYtC-uT-${G8`Gr$y$*c>xL%wAa;?VMS zS`F6CI$n&zuHsoa?he-GkE?)+^d$iCgdA&fp_vH2GDZv;*p5wN&w@CT>;*OlhK|8$ ze-TR$ONl6(9ToD-YNuTie$KTM2ApSGVL)I?6d<=K3IJPRLGrpJRkQPE>=4tJtd0g1 zL^6q9-Z)W-ls~D4+9{G6i8xY&Jqny*yu7ygladqZGNFFXqK{B;LL1f((H}mcaRwcE zeg;e1)a?*3AIJk~)h+HdaW#Y^NJW=UNQN|-Q7s5qgFlEhUSSJqk$n^hQW4H3!>cAE zuXbQwZ*Vpu%Z61drVXG8jyGllZkiBzmbD{9$U4n{wBE}5nUQ<BbTGnEj%4r+961|c z1jDQ;f<R|;t|Y5S=>SA0>7EFlOD|wo)KMMG;h>%*kCR|Qf=C^lfN!Bi!2%F^muf&D zqORr=fq{vV<zqugqhMFa*g}4YVf8tNFo_A^+cxa2tg+gutO%{zDjOp@1FusK!C3-R z!X+qNN#bBy#3gKP&QeiO0|r$<H$b!?i=>D}=OvO=St1BpW9)b)#{9tRL8QoPqi#cQ zB?QAEMKw|Ek&UNt;ITuoN+ZSwN#sQ*(F0zzEOgETYP>EDX@ts=2+&yPCPe=RK|<yL zs57QM?m8+1y_gK^m#AhS6j_AYsA#8{6oy3Bn6_6^m*XQ26K7Z^;i(kf8!!Qqx3k4H zi8L+T9`Oq>`iWZdO{A5P@8&?67NDrCms`G-7%MAe1Sg_*ad=2uBUqy!lS9KdkR96c zh2X5VgK<_tWm4?~ZI%WTAz|1y&Nn1SnrMNoCl|}G$_djz`%;l04)j5~8xBh*9F$3| zC>@H&LUVE%a8gV350k<<4SY*xBBj%Gl9R<?AJ8;!q=ObMwq8SG5$dI)x~KNUD==MK z>@KoM#F~inaSnj|9OojtErNzp-vMln-Ar6pnl8BhhBF(Sm%zEPP#}MZl(bkl|BH|e zxmAfc9|;&v$Cyi5Axy~EVHVW(j$nM&8KH=%#VZMTX5_))ezslAzM;a0@CT{4V7j~o z2rJl$lC@LX?Q?3Xw-DGAEv?nY_-~MIp))eT$r^`9v6ovS4wV-dQIZ^*X|aCzd}?6= z;B9RrA(jq^SdEg6K~)sGpz+`BFryN6eu*UEVT*?iZWcxsInWs+821Xvh#Lh&NdgwW zC1>7QcBnA0oRa#pXmuyuL=}mRj2bHp1dnVdzHiDK3<Wlg&qTx@IoIrFJwaQ_| z2_tlg9uganwngO>A@%~+2mW&$fMjh8q<}A*tw1ncb)?C6is&tN5tIVG*I@taTfowy zr<whcz$zr00(;rVH=f`ci-c)}rxlE(lC(e?IWc^q)g`ZUMUL3Vk#da+5&$qna+PIQ zWi*|zESL+)jAS?^!wg_B_{HR?lCwnGj-k`w98JT!;6JExs+34c?I202AApPqmHB*u z01=*dd{yECkBnNl##tZH6>ZkecB=}EKSI4^*Oz`fdxWaOhDz2spf=>F;D(bxMimfQ z6WJTlpyEq%*0N3=GOp85_#xT#4CrCf_#!$oVP><I*pIlg;Nk?4Y+Dij<51S*tdakj zZ59IW84Yqg1v3nVK*$PLk%LeZjI5C0L}Q#8NW6{62?ED4hv57={IJ3^0p298+(m10 z7aqZb#t$WNlMrYEo_CT>*%+sR1z8KC9p2B%CMgeNqZL@W03{iX9{^~nqv;aEqfZQ` z4Z)GxDT|;OE@}i(Vmz|?s3oi&vqR_F{4-SG#D|Po8>v-5x`4Aur#ferWE_7C7`1au z0Ygy#1@;y!Ev_QQ*${>-DA^)`9EgaFJmSc9VMuSp>%<k1gd%jW`7l#b8A%9Z$H<W; zD*$sCJxT&2zB3Lu7!vktgNsy>G(@cf(GD_;$?ihKkObrc6P5;hgw%1AnPXI~Q=5oi zwMbm13gqWB9F6G;g_g>_5<jB_{lz9nWIKQWenR|~^r4F41prWVw)hPf15}l$5TKT9 zBM=FPOTj@%^-tj7V6xH42Sm4990;*L$%-!6j0R>%l1KiD8^B}XToM8q1c2GOcU?K8 zgPT=wQ6Y6URk$~siIP8J929Gkipn-2)hT|%UE;7f_)Hoys6-&K8jsq6ipHD)_9iWY z`AI0Dak&kiZ&7s#4TM?)FCed{s$BkOxRP8S<T!~Y*<N*Yq>&g}>2MKVMeA&<gq?-t zML{S34k+457<I6L1bEeuWQ4gvVQU3Ij*$k`30$6Sx+9w$LnKB~QfP!AFI?1&8v(Pm zcx448O0~<CutEtJke7!-#xQE^%3@I?*a0QTxWc%y-;PrjT$)&-SfnR$(VR9xOqzI_ zE6oVMi!sT`EKBcIFscT?0z;4^;gVNkUW8jR(!oC@JAmXAXAP5|4KUPLB!d$<PmFjm zeRO&gbrbgH;4K0jAf+zq(AP3(McO1ON0@Sf(z1ra3bHvVfD%towLt+Sc&)V#ynvb1 zx(J9xgE5WM1Amd{kGKxWrLIovgdHialG)T{){wP9(p0ivB0Jfr3nheAm#K?vNtHD> z^=tAd;5sWM0tAIswZWRQi>VXxLmSs{b|e5vX%U$^u7hAza83ycf_p{gjjvWaBMD>0 z$zZMXjez$s3`nrAnI!xug+R_}>OxLNJ1CGWoPtdd1KWkn$*Sy1NUARLJ9Ncuft&<( zlXBPAiJjo&R8kujr7nm93Q`=&ttCkwY$kHFQT+JZb>(QEHlLt_M+PGI0q@Fw$aspt z5SS0dgsCP*wt)H+<evhi2Xbl2oowuVswoDbtdm%4m)xgyshq$`p_*P?xL8&n?9zA2 zl`?5Ms3?F<9}N=MGua-*zNj-Q?IV+d={$I_MM_GdORy5(NZ70(sUUZ;jMmv3fW<`D z0q==v+t#RXmVlgVD)~X|TI0}UA3Lcyl3qhZ)3y#K9{vD{Zl#OzoWN;tl=_Ym6prjH zn4VIY8f1>F4Jl#ga)8-@qu^gs83T^hMFJ%KIB0E`UWI~gUBU)TgR@>%T|F;4vmgwC z`PbTwW;KZU)DE!+Y#Rs1i1V={<iOz=0O_G<lUb;7$l1mUOVE)1o1MVSA>nL;U&;1x zX(_Q378}Si0Q5wc2Fqf0<q}c$$~!{}Qh`dBRw0?6pajMw_X&`@gziGLva?tb1kOOK zvg@)~H}WqEU^xn+Fq(4dbovq)nex^Ky_~$SE=kN3ch<JZN?<!DFh<8_oJnMS8MXka z<T3*%js=66NK3Mo8`pqf3^_^NbuCWe2jFpdn#4(hT|VVq<hl0ugF=#A4^Ufmc)g3z zNreGzrbfbv&V)?~JMa^NSBO?4Hi7i6Of@fX2heE)EKHgw&}z*+0=&nbrL(_Dat6F1 zFNJ&-oIiY3@*zRBsm;UNAl_i80=vao2C^~9l5zPYW#Xi`0i00?W4jad2?GJCOa2K# z3-|&PCHVdZybs_>TaR{3YN~n*7f@12QNud~r(1-r)8ry<dY(fO2@E-vp8?DqPQOPD zkWwP{EU_V}9&mt_ut({_Cis%WL0~r$B_cHjca5r#E}p_VH-;FrT$H0yc83d)@w!|d z3mBqfYb2|5YHmqDjJ)VX0Gk>XY_YD40^i=XPc}73OktrNPaqya!WoXbc8YXNPG?O1 zSoAWHJ=|JMUrsElw5wlD4tf)cXy8Pgs^kDj;RKcBnuK5&r6q?Q_roa<xtR<7QMzVb z;CoOi&KUKf7(rxZ$lxXsiHL2>siD4!AQp&^PZ9?dDNc?z8F7^Fq64ry0U2uF4Ny1* z-^t`;3^ayS5&fktN8f7UG-yIFNILim#ZBIJ#z>?R0d$S~IjHDBSz_~}r1^Bxo`bC{ z3f0NTDY}3)7pvHWVzqqX1|^|gYB6p#TS{_)VRX`dB>EcT(TKM;8^Xiq<zQ0<>HIiK z*vm|sh;MTN6{QXlP_J}myGsnwrqpI|`Z>0RT^1@Ih?i0qVc|mxBG3@=PogvkJ0jJf zVVL2*IRn*e*B~LY(Tik0SkM9DxBwx6dXbXH;UnMCwY~&Y407X|5!b_&C4~!kk$E}o zCiy}Jr&HkMa^Z+sw=G<BN35P$AKt0io9bQtl?YR`M^|uD26{f>lQhOJvH@$r6q_+9 z@}{fb#9ffkCt8G7H8jfQ4pgSQtQx&VMl@a(^0#nqfp4MVZiV1tc#HtD3P{NyfC5lK zesKi$CZ8iZS6j{ovBeVAMpb|`Fn9fwcBHb`F0q+~)2qn{#H*^JflL%&>@G7Y+%r35 zYOgkfzZfkcX9k1-&ww2OSt+t_L?J6Xy3mBXVklq1j0>gnt(|_3`;GSJZw31driVj~ z&xS`#{zZ$M2dvHuL7>UiqvA0*ryZq>F2#h4z`SIGQku+_5J0d7OgU#%ibeaH>;{=h zEzDdKm!*CHSGlx8#gO7&1D4ED9cnoXd;um&1rBGh&AuI}G+2U@0w1VnMFKw7XIJNk zE9o4z?BZCbZW1gbalJ(;kv&1oqH_K;x&vd>wFP)-m|f)la(<l4M>;c30U1f8SvkRl zyhalHC_%#UD~!Q#HjROk)#~IqG6UKUIi*~gudw~goSYHpT81KY1#Wd$Z$&Cq0cMT` z#;q+b<-z*l4^=%BB$8u57Du9N5~n*_uy=JB4Og{LuLq80M3`!2XHsKMxNHGO3eeM@ z3VDL)nM_cP3SmGm!YjeB1c(aPJ)zjS831Pne2~~9`Ee9RB}2i)qw#@jYkX!vjxD*( z1QDF(!Z`>2t_&9wam5xS=w=7Smu!$bg;5O*pbgNW&YV90C2GE-b(F79$qtg^oRNj? zVo{1lQkR5E(7_b|$(v491_=d7fZ+Nr@)tlDjr9|8wTT#A>;xYqA`Rrz;FuBImAG)Z z19#b=>M)%<@48|xwr6y@d@F~q@gYV+fn9PE4;Fdhf-rKFIbbA{fmGJcJRq<pC6ANu zSR_^dKsL-CAp?wvv^E+{(G`FfksahGm8`IF@;wa{qBky6MC+AZeJ=4y)`_X}SPm{H z18_sgkS$CEI<lUm<4`h2?GY(})K#Ia@K>}wBto;w4j09)0F5|NS#}9azAJ+O9yWtc zGu7$FvPpVn_<}P{QA$k_niGv$L)w9$DO1iynyJ9T=*JoW;-@Yq_=b(_GvufuxLS7^ z5ef)SBT!D@5MTi{hKD1@XhF>YpUAc-olAwi$)<8-(W^+n##n|?U1w>K?8XjbYEv!B zfvg=52_*gM7*o~HoimN^62i=P-j6*Q5MfYT*viOh;FcdfK~70@ii=Z8?dHMlSdV2_ zn=Gjn(IgZWW6puK5D+gcPaQmNeOW_k6AHVUa0?k-Y-NiDO9(7Gca%d5uu0xc<*;$% zOW|Vl)d39*K^_-{4#}BHWWZKs=Q~83{IE~aU0dRsIkZv$i^P3*vY%0gh*hBJQNZQu z6@U~YeT1o7C(l~kbXx+bgEs-HjMC@iR9z4zIosJ<mV`z?z1C4I5Kj{B3`}s{1=m?| z(N67zM_g`K9Fz`<p|Wazh@ZkWM<kDuoK9{iK4Q%sDY0>tXN5E9I+q66k)SVOG@>L< zDgs6%<$#Ls#uo~Z?uq(m>VzvfzSOeTV9R96JFe9D#wk{Wq-++pc4jgWvg|ZBF0pGJ z^ud9x95KS@lhA3Lg6eW^$G8zM=yd`C2F4MFzWt7?bO5}l8)$s91U4qV0L5Stq?ar; z6hC-AwGa4;0JlWJiqsjBf%0+Rlt^Y!vdBV(wxD5iWop<U6pA~Kk;04CS3lIgvLm}l z)}?2q?e)qvdE9N$fMOA9v^*l89P6yHgNFfvSmS;?r@a$S#?kYIElyJ_0Us#m503W0 z@xi4m1=gT%t09M!=mAz;rg(%4S-PYq6pvQQ7rb@6%>6L1G?fE{d5k>+6j9Vm0te;^ z$U32CG*$v};7FjPuvAdWzMz0Y9O}x5ZRR<XqXyfHc8gph2f~7X81Px~yGV7x#?8@{ zuw2E*2E)0XCJdboO1cUr4)rqF7U09A&LiF`j&kMtUXmZX<UgG_*W<UoIL%iS)~?O- zwKK`VqJ|(A`NF&n2?l3XEDW+8>q@p1ITZnzt3<yC#G*k<oLXE3mawMa5M-UwjOhIH zF1fRI>8$NvyeFA55sQgDB`PFBS9fTrrMrrSoM><?_QSdKu4Z<{a79{j31nMDn+IU& zczfJI<Z2+Ue*`u&L$|(I#J3pn;eexfe$G|F!R6XM%nB^)++}C6s~ED5Y*FP5oQt*W zyd>9=qHs|?$+-&!X#+sgzUnF0jyGbQka!e)&mN8dYX#H|c<5_B2!^m3WXZZrtjjNK z4HenBjR+VnBqPJs0nNraM|R#xwd-zs;$){THNxrXuDJ6)a$~6Gf^#MDhC+?bo3t^= zA!uA-QW}s2g`qG90m>th%R2}g*hZyRAG4E;Tjxm!1CP`aL<f|JrnZjZvKYx3;E|%M z?7K8UN=Z;>5lQFDUH%=uD6wK(Be1>hr%V#R124dr9I%1D6(kta;Wp0Nku6MiLYfhb zqxBTY6Xv!JHpEE`Ez61BjV|gCV#+t24R6HOa<;OPDp4aOjb#GQjye;ZCG`b;OtuBk zGjTbBhnNCR_Hs5G?p#7}aWyCR!r;DVpGMe(A{Q{INM&nV*mtkJw_Y4BcA}<(doREz zNleL&aZ{im={?_3=bCX;7`708Jkuh5+mSEAx-O$=eX$NDEdWZ`8C=wg%|s<B*CvsA zQ*+q@wSqBp&<+<BI8`7z!HP0X->(54O_>kT2&yHByRpt>-%z4FSEBE$P<_#;v*f6P zBizL$Hw3@{A7P8q1u2|ua5Ox?29*dlim>D6%V67|bOqAt$l}S)gzoT0Oc6?D8^<Y( z=##!t*k8xcay@hDdqF8><~x1YXzU<jxD<Swv|G{=Vs{0Ruk!PCTglg<w$6g${y&67 z+vON~v!YYXsqDsXX5sJ}l7VXKG#bEv%DT8u6IY@voR);d;3gw-t9&~l;6dvEHfSZ8 zB?w|K5^<VHK0a<1#vG@Eth3s=m*`gxEq95LZV*AL2=4i2KFq4%d>+(3APR{j(RGP% zn(sCAwGO4zXNmh&PXCLpp#;cBp}Ibbiv-94Z_zpA#6^2ipk=O;uYKPO`%Bgi=m6TK z?NU2^*;HZY2z%17Fqi-M&Pf8+B%FW<iJ3~*r)8%^;IQGoxR@7Z%#}8FKkQ8sV@%v> zKspmk-~{{v7RNTpzFCWJuL`@%SSj5-XUSQg-0jxblfxHrC>r;WXcxuvuu{c!Sf$Gx zt+X(-$s`Mg)Vb`i1?eWJSNgs-ZbY`JPVp(ILu7%1Z%s=^x63XUjM9SIvWL)!14?!m zxVREbfO4DG)zD@31-i!El07aj0Ed(SD@IW1t0CZ`*4luIlr|ah1dsB4la13xya|zm z>dVPUW@wxMi&Y=GN@;?2+*J+WSoq9F-%G&NcNF>iQYbDC^wI9_9W>fX<{c5#)ZKcT zTm(#QZjQd$3J-@L0y~gkRAbBN%jki^#m?Z8p=gW%3!5Y#&Im{kaZ@r~Dg%N5zm=^j z?$^Y(L2$Cpl*x0$0|~TfKcq0n2gBb-n1Vs1G{up%)1|mpj=SXe(vpC99euk81`!u} zV|su|`!<>GHXraj(#p8RuW;2V7nk8I5ijzkFV4_*m5^_*;<$j+IV~LD4IB&HwQ{{l z?HW;1WU~R3<UA~3LGFR1umyC5KxO5hQ0R;BZM%v=90BqV0fq_Kb!FJ#-E4JodM6Gl zO5Bk)Upm~y>5$;mA|f+VSDl!AaY^ICDk_qxuC`x+nE~|gNJHrgMt~XuXk;Dv?nc5Z zrAr<ud?L%PGU|z2?0N|dPTzonmqcYTmH1t)N8@rO#0<kZa*3r=IZL&0vH+gD3-v14 zyK$V3i!`#;4f$Qz^u*dpOCl2<B$!Y_@J*jo16RJWgWzCytr^e@`KoYB_AS!B2-Khl z<{P@V;kq<iZis{AyNSAdd?MtD)O!#j%9IGfU@ZfnST}T~U?74hMHfy-Y^Ll@D_nBW z*!nCimV9j>unYGZp*FZ213RtoC02kp1m6MT9H0bmNUif(jLhPM<G|P@!=Yh<zD&w@ zkQm~y@M=0QoEz=&$njAqj)Si;W)pD(TTG+}VZ2GIVoSG<QWDk3HoLMD!KnmpeL)g- zg1tEIz$AV`RxMT(t3)|#c5+zjazFGhi-f&TSzqJ4Ywr81xHp?<2+^9xSwTz(g>L7z z=@Nadx=9HxyQ>Sh*TF@hn4wa7*sFxMNn9W?mfO&9NvIYgE!THTAg=JJi;gu3=D7?3 zkGA0=Y|1>GVgv?W`<_QaLBw$?z6cD)=a`_8vn)WL%T8^UzP!y)O7Pve+zL-189_n} zl8hObNBBy6KtX^FUjyv|P<#XoV(w7j*bq<kwUCXk76BbBZ9@B1TqHp715*KeiZV*7 z_6Q~taVC+@Dd7N?z^5)=qKulekh@wwQX*_Ck-$rQ89m8uYQ+B?hesY!%uv~MC!oNY zu8rK25X~*hC71*zs||1N!Q_So=GO(P5rV$lq3V*GsTL0|esFvw8&2<lGveG%Kp~Ng z>*To9(;AmtZcY&P6rpRjmlUzWH-k8Yz<;2@x8b`4J$1LSw!TRPh3$Kca^0mJIDU{_ z#7Qn&1)7C@=cME8>qfil%Si~sD5+gi26XFs5l&)o6%hVD%DV7>vSCh+I@^Te66z$d zN3nKm|92OHFH<4yjXTjPgkxXvdz_7kwL?A<+K)`l=&K?~StGg{2~WaE#FL0*JEz6* zbC*Gp>+Div-)ZFw&g}ycJ8jXQI3e7rt2uNP*2(ZTs=dK<=&EMxPMA`o=t~y3fu(lB zGbSG=nfpu{ut)G<YE%7G_El3xXPgQ~COu#sDhnqP?8NuyYJItLogzb=aC}orWclK{ zyLq|d3MFh#^6|`n+BRQzM%V)91=|D%fD3*I`vY==P>@?lhAfvnQlwD%Ld}923hMMx zF2VLI^<(U94G2J1C-z9~91LIm<6BsLqYY=Cy}>3Xt)7o)T$9(38;^JAs~#!Z0b?go z)=(n8HYR^`CMowW7t=q}Khr<cKhr<cKhr<|pa0qAzgKqsnHx4gZ+64l9cx!_+O}=Y z@@H<`vSr)y+07f)EZ5(cpLOQC=kD0CZL5E<ZpYSg`B^t^JoB{fhy7nxyZ-Vtz4@&B z2HR_9!+U2&qu&?(iRdpye<%8q=-Z+ni<T}LjSdnWB|2GDiPnfN5?v{}PPAFHL-Z2S zt3+=Qy;bx(qW6nFBKm~r)1rSAeN*&9(c;CU(E*~vMJMoI(iEL8I$!ie(KVt?bN@Zg z|0H^a=yjrB5#26&kLbgqkBdGf`uyB~k@H_fqdi8WeMN_gjuV|C%A#{bj~6{vv|hAT z^a9b(i*6IWMfB^UcZ=>2eN=R}=rf|Ph`uZOiD)nW%blWQL@Py6bhhXc(UV2b5dDnk zd7_&|w}{>-db{Xdq7RDxSag@@Z$)1eeT#R_EInvu$z!)~U;BcYnR{EymMt62>@%8K zKbqNhX68prym@M^UaJ3}aq}587rFU*nv321=u-ce?P&hnQgav0Q?&gvOWnMl=ALf8 zj^<u&{wdA9-TWcVecW8N7o)m)9nJmRd@arW-TV`p2e|nIn#<gL^xkS7=;qUD9^~e0 zXg<QtKc@LeH~*F9!EUbHN6karyq4ynZr(=oQEvVb&BNUM7n+B=xnf^6k8txEnn${M zE6t<a{0PmX-TXeyW86G>KQ)ha^Jz3^-F!98<J|o3G?%;iJ(|b6dD8xBp5W%yG*5K% z7Mdryc_+=2-TW@i6>gq*fSN1ad@9XHyZK8rSGoCNny0w=9h$4%JYkudr@HwRny0z> zDw>6xe@L@*^V>8lH;+G1&EV!$G^3lpNV9hH4`?PgzeO{<x%?nC8#kX!vvu>8G*5T) z4w`4U`Oh@Zbo01JsJX_?C(%61%~#Mo+s)sn`4~69N%OI8&OTDjbKJa==DBXZoaT9M zeu(DzZhnL21#TXDu$mXTc?Hdj-24Ta7rXgEnwPlwb()vDdCVbdKF-a{X+GY~pQrf* zH$Oo0GB>|Q^NDUAeW;q3yZJ<#SGf6eG_Q2?{WPEC=2vMx+0COKrRG&`UPkjNZoZ7> zQ{8+Y&8yw~Cz?-l^T@;0yvEHZ(7e{on`u7X&G*v0&dsmTyxz?t4p;LTZa$voS~p)x za~&do$$QlNkm!@5e-`a~#GKe!dfB>XZCt-&X3>4k0}njVT^_AR3elyaO`@OgcUe5> z^1FKEy`sMqeND92k-aW^47!}GM^=k260H~A-0!kv(B-Xq<Tpeg5q(DVqkfmAgD%G% zB~2zeNAz^ji;n7b*>lk4EqdgwqB}(Qh`!(Nve%%?p+`$+in8bm(X)^4b=iB+<u*O? z2GP4ke<Av6zso*@E_)p#4JukGI#0Cjm|mBC2VHK~Bd-v>UG#^dzwdY1Z_wrc=#eGI zjz+VhGelP(+v~Fbpvz7@@?z1OMeh~;b-&92gD&6EBR>!wG%GF;T{_$AvTV@hXY|N( zM7M};7k#wf<-p-6dgKS9M;tdAoho|ValI}F4M))<&k@}sx?S|qewRlKx_nKKd|R~d za`Bqz{N=qaj~sN_phuo1`UTP3M0fVP96adqc|Gza(dc;bn&|Z7dtDA0bh%oOTrYZo z=nbOx^t&87=<-QD^0%Vziw-<Nt9C-K%cBNeo~B2hA$pPMjiUGUyBs#?@@YNtS<w$g z2cIZA^Tb}4!v|fi(j(W3o-ca6==b_vju>?LD?M_L=sTkQPa2I@oz&}c<e<ytdgLjh z?V?*n@9cLuYS85`^vK<!uZ#9Pc{Dol<X)Gf2VKtBBbSOciC!jpYro4e!%_6e-J)-Z z_F6F-owTCY<=8=&i}lE5qGyR-E_z45%j}@b$MncuqOXdUtdyO;ve)IfL6>v&$i<@d zqL+w%wclm=pv#B#$e)NlFZ!|Qh)4Ij96#uCx*mCq=o-=UMZetda>Ag?`}D{iqI*Q& z6&<vy*X6`Pms*dUA-YPmUG&<1my-rv-mOR8FS=XwP0@a*^tzlp=u+sBB)VL5qv)1? zmlcC9zoSQfPxJ}VKZ*8S-RrV)(52ENjp$0zHqov9E{`5`d6yn}kLWJZ*F<}t+Uv4v z&}FqA38E*6o+bLlewR}QU2fMSzbpE<=u4tKPV049J?L_p9;ro76m1dxQoqZogD$_V zN8T;^bJ3SYONw5X(*|8m)FZ1z7l_u0Ztiy}23>wrkGxCtG0_)Ai_2b@a?oYD9$6te zS9HDT#r-bTpv!OQk#~yzO!NiOqN>*=49y-ra<b?g(RHGq?RSZTF7MDIzb*Px(Labr zq1UAzbU9X!oG3b5bdBhR{Vr)}T<MXwitZ47TJ*2|E_u-9kT@D0DN3R%M9+!6F3q6J z>-5N*MDG#(rRbmgUD`pH{cAlUI#qOuXmj1`a{8dlEA_~&qTdqzspyOSE@uq7EKWLB zq7y`q5nZ2pUCtbId6^!0rRdj0cZxpO@3Lml<tKV%aUPA15uGl&I`_JqH8kP$$csg9 z7QIjOseYHU2VMR}kNjA4Xd?wKy1eOidCZ{8v-QaHM6VUSOZ16;m&Xped|i)xN3>t7 zb0fO2?R7b4Xu|1{=ZJ0*-7fmGewT9xUB0YGz9HK4blF#;b58GdId9Nqtsc2S^fJ+} zivF<Q<@`aHf6yae5iL4Hdm~zNMz6~SgD%(Vk#(Y<6}?&X!G4zuhsKp2`K;)NqJz)W zIX<)3<)T5CEA+@yMK_6V6a8+#%f*8(O;meSl4%;R+|}c8h1u9u%Y;4aOqa=|i%Dw0 zD7LKI7}IIW+7X+EEE`Kl1&RByGB&l?*5<IO$-tD%jMvh<0m_JhjgCMz<2A6z{Jez- z3ZcNh>KxDh^PcB>-rxJXeCK^1UNzAzg;<i*bZW-0w$|jm(A;Hg_Jg!a=(xl<NpGR1 z{TsS1i$DG6T~UX}-&CatHU9n^vDpvPu0jtao+0y`BUXt2H53)dIT{hoiilpAP7!Vc zL+t^v7ePjYN4d)tF7$6@|6MS$!x^J*FMu&VuI)znkR`|{vh96+{h_9LSu!qywRXpC z11Z9t*S&8b6C~Y-Fa;SC^p@<j1?aZD@NEF+Sc5T25l-4nJ@tV254|Z~`zM9OIQEqA zL`pR5aPHFw#uxU^&|1LjeIJ`$0LAH<`few=9Has>u~dTJ$T?yw<_e{-)-5zcT0?Tf z->8q%#u<w6BzUX*s9>o8@{*7W+J?<@4Y5L1ukgR`J(g@M%q=rcWiMZ(`L30L_%-yI zE4&|YF!PoYjs}o-3~^&?yZd~|DV0RSc4wwU7H^!Uw`Ay2+x^D!3&D5~z*;*}gi~Ph z>O*T0;1*=*@$<5S6kV#e@b$!v6aVT(RJVWEpE~o2V)AxU0XLB<g>qcsQ`aYt3&Pq? zvO=TD)cGfh@F_lM$WPj~>RE?G)AYf*bfL@tHM(zKA<X;5>1<uktNG!^W`*WEdnvZ@ zqM_B2$9qg2u1LgO8nGzblOIurwHHU2X5&Yd8rb3KGbtum^xNoJZg6DAv%(X`=3Ljp zrQ$br9`?A-Jh12(Oz=YOHs&pcpeBDnmztHXTQZou>4d8yWLPBQYVP}Pi8T7!VsOtt zz_Z)D>@k1}`B}fAIqTT~QA?lZYWPmQriVVt)fkl0Bbyxq?_eWl$0zNVbALlWODx4? z41U#jUr#DAL#|s2ZA#RI(c<x#ui7b@qntOjSnn&${=B53kjwh%&U+~lW-$tz3%P`+ z>lllPG3QXy{(G(L^&4m%VRIXzTuO#ur0D$onAX_HQFX%cRD(+NSPADnmlJWUgW9j3 zY`D{PO^jNcy;tv!9iWZoAbWEnxsX*2<0$8LVrq<yG*t$&A!{1P-JDdEG+JL@+&?<X zfOCH#nW{qem|xbCM^D9M8$$7%=`L0XZ)o8r=Hdur2>b}V+4mybab)DxL$6Hc0n&&= zEQ*S)$4=ZWZ8E>j3ziP5wXa$z=O3QU6>rN}g3#<{(#XKeKn3**MgCsflzoWyx>O^O zf20n^FK82kSdYG(@qB65xbuB?;w<&T9u_1NpqLj<Ref0abFtb;H<*l%bR=V@fzZzE zkk$^#X?@=#=&nCnk)C-!myOuVf;<PgkV{4~yRlhT&4DUJg{3jSMww+rI%kR_c~e8x z#TZ^uU-X%!;XvmE$DCv5yQ>pQ&8r8d7$lPm{%y%bw~9=3D^)+7Qwv;T3&niA{6zJ} z#AG|?4fd)a?2c9KyJ#VJ^bWCoN8vF&MrL`(?_t42C!uk{Rev?yg;&EBP4>2dn*@w^ zY1!_47E(=UqE2^-xF_K+91lIYVsZHs;K>Ydm%G(B*7M!#WO&E<z@MgAAcS@o^{KtY zt`nVxbSy0hwVw-paP6O4<7O#w>4@u|XK{8`nFb_9qp5n0m}26)f4UZ$YZ^L_?)(oD z@8}O`eQo;uiiN=Ah!5kA+_;5u1|zD*cco`0H=UV@`=-TW;?c#G+~;z>+Ypz;`FK06 zLuVA#O=1+IYT9sP*zW{e@NU6YwzD(H=nH&m{9eo=#<8|`G*zX!_UX1ixQcy)xhi$_ zkTt<1+H1B13bdczmA|Y67^Gi_^Em^qINPB^FlHJ+MP1U#HmOkK#R3$sJ->ztk}aaC z5I2Hp=i@%_(D`K*I0I}oq3B@zTuOZoFW`$Xf#}C?x3U+n6pdL3sK~rQIyxl1>}fQ2 zi4wr<)!eNz@o~8zfKJXYzgIUYlO9v2?k+-k?&p_V_q?McuHzVDg5Yp@5Z+e6KiX-7 zdul>!mw12qLaqIVec(`!LtJSgm@jc!nKKK)0UO6Q;q&(ee3+_!R{@A~#D4f*ObFgq zA}YAEDNu#PyIcIQlO}ebg&=Cui8U)I9uTl5YT%q7Roh3M<GlXc=(318n_4<?lhhY1 zs=(k9Gub5uM})$1fobZiA%o65@$On<4VgQ$S7G_SKNW!1djEfVqAeWoIVWiVa20kC z(6w#CnS9C(4x7@8l*wi)^Q0IYwm}cpRmlbx3b(4dM(9ldNZ`h{dyfG$eS(<FY+UCW z04QSP_wQ3!CSv)3IwAvF&4Emt1qJ-l@~72cUan~?owL|w?O8EU{h6}73vYM{d?MK^ z$RHlz_wvWC+92#dwQRA=0RY^gzn)u3vb-1ThX*Ti*_`u&U-R#QLEd`G*e~m-KI_;0 E4-Uu~O8@`> literal 14008 zcmV;pHb==pRzV<BZeeh9Xm4~Nb}|YA0Ih?Pz#@i>6lCVzbDVNMj~|N&00000000B+ z-CO9c>3J6LHIvjp6hrNaZ4j1IjB5xn@8)@TFqt5QQd$obH{b^2j58Bgna;E`tL-!% z*dsRwwmGR31VL$0q#n8frQ%5`A_Z;J6YGgZ1U=B=fw)1ue%HH_%*NQ@nJ_E)r)z!x z?|Z-ZeV%)B-Pe8HPyfU-4<3B{!JD7_3;*Ch{hROm#sBeF|MMUHOV`hTYhKKspUKaQ zZ~V^h`5XWI*-w1iZ~e+IfB#SXy-z;VSAQcvuRr_dkN?`oe|G)k<A3<d-+ko^pLn*f z{+?&<pFftL|N4dR{OLdN#Xt40f9_xW{Q8If=CA&vXZz}ZeEReDvkxA8^x^k?`FH%p zcT9i&yZ+~I{K@b6SKs?v`s&|#`t$2ge;$71{`sM&KR^BS=kMp|6JPmXfB5?DKmFv7 zJow3f`m3M*^2a{XSO3G)pU-~u{`qV9`7_t||H@zg%71(27k}v^%j+Ne<Ue_)ul~FI z{N<nhm7n>MU;Bm6fBAFQPyVyt_6L9cnZEklzvaP$Z~K>@`rH5ImtOtSkN)?cd-A>i z_B;N{vwih<J^lHqAA0cMZ+-iZfANJ+efoF5_V(}l$KU<SFZ}yw`s%Z9J$Ueu2OsMy zKJzUPzV+FkdhqD=SD!q5^yr<3^Yr}lAAk7p(c{-1KKjzDZ@u~Xhwu2eKaXC1^^1?+ zc>0h0^OeVM|KRH{{n*3jyzjZ^zy6CiUj5P6AHVVH^S|i_-+1%M!*BTE=bwM~JwEgK z-s0mYufFwx`*fMF-R#%C^nUAS9_GCtxY(yY@Vr0x*5fyx+|T;8zrXi0-}%+ge3Kt| z_Afqo^k?6E<CT2mwKw1NMSi||cYW>A%P+n4@a31j^tGFQ|5Ckct=@UpB7Ja)?+d<b z8C^bC|G<-f={LEj|Mxrj2ABEzjlAbRe($4KUVSZ}yWjBWop)WbANzFn?Vb03=rjNK z4?XwJJMTRA4L<tWuYR<jeEp>#c=?r=K6r(1@Zs<J=04o-|E4bZ?eD$d<F}tYoF6U^ z*Y~~c6YqXoHtKyV`1X&z@#Lj<KJ(TOzy9jm4<FSMAARAezup)9z!x9?=MUW<dHmY* z-_%9^`1>yMxzD}$)z7{3F#mY?^3zYhZ=oK&#PVLqg1q$ZrF-;ZUU~WX518ujfBN*F zxxdXK_?8boz`Jkx-8cQ-%YE|EqkD}%{_y>O`T83_n!xyl<2`Qt`1Nf*$9&GyK8<ra zkNsM&bK1`NI<8|Z$Fc0!x$WCLPt&%}*ShEJ$1&~4vhMS|jqTdTa*ZRu-1ljp&tu#6 zeXQFU$G+^xInHI?jwQccj(qZ5$1<j6y5{`vy5$1<x=+V;?fX72*EUbN*gCD-wT^8% z^L^8}*8F|Bas$UX9l577*BHyPjy3N-_x;?avE(9SJN9{Bu6*f!9qTpi>$IHHJmn%= zp3v9l3c2*0r&`y;f0sPalzZII{B}C_X`4qL_`J@2T>CbTapeowTqO6GZ`!j+=Q;Aq zdaY+}YuYxqxlOs}b-$K%$z`WJbpB+GvOrnj^~%4mD=T{CE$1?hD+_Z>BM-9ez0*Al znT6Q8j+=*^kM%sRu`ZYOSg*04^SR{OdFEpsXYM#}-SgnNel~B;V;;viudL5HFIh*w z%9douj%?X-<Qwu_S)zH$?rm9$Yw{f1aps2CJ&U?*^PUCI)y}L%3?tTY<$mTY^RmSl zvP|=m_1yN{!5%xvLY?E7u4~SH=YP*JO=F%`E3s$4yA#>_EONFqCY8U;xtUxqt2|9h z79{&06UoBmMzZAj#(B-s?796I&g#Ll|5=<lJG90U_cLF9&U?(|TIR9l!!gn<?$#^q z?l4QZZfh?$Vz5`t_lSL7%al#Cx6`u3=3=PRc}_91W6l=EQaoyIcDA$ooD1h~+meON z7RJ`kW4Mc4eB_B|Tc7*e^1NAwJmZlaIAc7EKOW=A=f}$U;#qN~?CiO&tEIoPM{YZp z&P|;0k$mQio5ZEED7mmLXJ+dXx3S4F_IzYmjBIjlFy?<`3$s{T9@$2$xx$>EEJPl3 z$>r89JD%^#!{+9;{CA6SW#vYeEY3ep7aKe=cY6BlmEYxsY0mXV)_}?6mSb91wk+`? zOE+cj)+Gy)a4_~fL-yqG5b=;X+ZiLy_vDRkEY`G-u`%Xjonw6Ys$)H}Rny8Qk0oxC z``C{;7d_%*c_uD%UD?KMU$P{zp4@!wEN{tnX6M%Ybz+AMY{@po2D4Z(^ti;f+U)rA z$Qs4Tt|^;-dEPy?7Qa8US9vwpj3wq_^Case{=^@~p2yv~WouSGhPE=v#I<<I!OB=p z-f`|(%h+>vVZ`0CxHFTCy_`qvYRNr`LkUAi?rvUIf6GEPg2e1%QTN9ab+dmqZ0|a6 z+&q`aJ!diVkf#`uEs8hg7lKBtdSMX>Q}K}8SAx?T|C{qdLhB?<$7uG(rv%1jzPcva z)kL3cZHzYIK5iHT*e=T-+f4|ba`|jRo*|FF)<>4OZMOZ)EuRUv$1JoZn&plX#`B)6 zRjw7YJC_95M3O9E7BxE=Tg$y4`Q4Ssxy6Wki)${PB|J~on9nBko^{wM;Vz%e_cb<M zylvveJZ;OKB|uo$I7aLx4knBo(|LJjE538s=9Ao8V&3M)7I};b#yXOr5~X5-iFb=g ze(j7nz8o9QPG@~`OKV=alG9>=vskqbc9!rXV>LI%nsRHgR92APaDNE`xn`1FEHKWJ zH&40od}*>zjQfy;k{w5)%GHo_Cb#WL2XT;TiEGBtvt?T>Xc-9+`Q_@Px!bHro;2U+ zrAY$FJNE{+ku}Rb^QDnbXEkz9bDlD}FHe|z$ivzCSkJ-pviCATEF~EutG8QM>B|CK zeML4oVj0sRs3hLzZexoJFBl@y>Vj6mw#V?YPKR7oV~(vH%zFr|K@@SGypZRRVd`Mp z9pAI06NHc)5(|s9$HJvzcQ}ifzA=`xxs$B&wk#s50GzkxMkgki?O-cOf!WV>sjFuJ z7e2W9wh4YnN|W^@pv3q@fdtwFnXJMt|8@%#7l4GgPTrhQk=S+kMDlLF(amQ=vj%yR z1c>CcU4Bfm8gfe(=12xvvgEnm5XfR|d9t`gt~uoF>`@|$3@_<THZb?pT}}?q%LA-% z!B}ogBb$%~Ph3n4&UYm2<zeF7$tfEsm8FhfOfx)@3uXrsd9S*;T$HcoN=J<-DLo69 z6-rPNG!r#9J9qJn<g;1mj9DZMO?<|h3~77-4T~j*K4vbHfDy|}<d&&c(J42S-OPW) zZ{C!>;qiMdSB{LC#Gi8cSX!bWC^LgF2`|~JGmo*xeY5p3z{Hg-Yo2AvBF8+YMD5(* zJT@UT#+6T6jRwP$*=$+-JYhUHL4P^}VWp?--n48da4TxVWHTIbB$b{lT7VL;vY9hj zDA$an#pK;p-tvp!r;T085IaZ}JKWfCf>pNhNDz%1Kn2PDv5{PRnZ(#FHyFqPx+PQ3 zY<;#Ed78PnDdxY5pE0w*Mq4+0bYaB+E@yF9vBhk`A>fX60OkUDY-6!Tc|QmhV_?HD zCA60fj(I2ZC!HpM<(6Ze2m9TvtBe$DIJsEvC4LrE*IFRia0uOb&ODjq71I^p^4>%@ z_+?1MjFb5UgvS)}v~jpa(&S*noi!Iu%7H8b?}FPC77~9G{bB=fe%2s%%Gw)Flo}qF z$+OAacGmv5gJdAZ#vxYjbSMcx{FoEC&+daFMdLZ<kXHj>z{jOfBf&8MHjyx!;%@Uy z*_42&rkNGgjdO|qi3_`I2xUkUvAP&^fkT3CKA#6k9?2FLqUEj=j`H`sB+y^^kchwE znL5iOS|q|}?Sz>aaDYkxU{*#H$#w?T$NmlrJ7A~W#^%HM{v``%_h-AAHOe9^qIzO; zmLpCrqTOY}#AstbMJrjTCW~a1RY9_WcODqDOH5qldDb}^LSlIvD4O3TdhAnEJ(v^w zIo*yb=3ooCe*i&F$uEOy^Pub2mCUwhar5lKGlw|XG`ovB>Jz~06tbA+3Zn#!PIrA| zCs+ST4hcXHGTcC~7<%0T){n2U;%4=R>DjMg$$(2a<^<dirgJ9f94tTXo^OD3>!bmv zG2FP$1w~xI!y(EhD9-B0l~E6_o?M;a7K{>q0WI=dCDSF+22`J_j0MPq-(tT>$3-yW zdmr@RY}vo~;ZV)8k)(;arOyO1=huOL>g#M-5|YAs2mDu9D(*4~p80@;AtGlF1JaXR za#@Hlrl)GXydwxy_?cRqEU;1PkEx59pvv8$7T&qcH%LeV9`bhLk}KBSveUVzJZ%;~ zP%!Qq+esMPWz3}fGv(kSnnFLZ*_g>JTPtrlR@^oCDmWzRSUDAY*?H<#2c4uN1pt0v z%L0pN3;a?unE6P)KlYgr9W%^Y#EGR~<ie#+OsWU~u{YV47*mWRtCzLOH<ZQ5I^=@c zl}SaKWxwMjqlkeBP|6iyU{YYk8k0>Ym15o@$Se?8ykn9uAlY0YSO@x5C|%0)c)_ys z|0LZY-cxvuqcY^PU?D4(Vn4Swj@vC0UgNZ2g6t^fZ-t(#6tgxYLa{3*U=@r{)msoe z0174VP5t?Lm)JOODw@DdRbeC40jTDi@DQq}Sl|SHL!t>zR!eqGR?lB|)%%c+X9hdt z3sxjVB7&MMcjfoMcW!*fA!Nx;g#^beFSH0G$+45111u%t^7}>p&Y~)USc4)X890kF z8b$I6Ou;VgCw|0282ZAs#KEjU-nd8@1-hu6EbzgIIVjJHtqyy&wusJiC{^q8dDgh? z;hFO#yEGmru=7{_W+>e;LhRsve|B;Kf_8vm=K_noQ@$u^CJUSRqntQeVCKeE76FNg z(5HlrDcccO8`5YK4G>dVG0-RO5CaDT6SEuBBx<;{f%Q`5#U&C%puRFCr)P<)s8wP; zt(x<gn`&omH4PKy-jOm3G#86s1?Nj_Qv}Hyt9%c+$JS!D0Y+N^KE#&H>*HWdZZFr& zjl~P&JF%A-Jd~J)E@y*ogFuw0iSqVc4RGYzQUp8^LrtWqpC)m_h8!vPp9R}6B-zJ2 zR=j>#`K<XsfgGYJ2n%FR0!pkeuqY8f5NML5C7Py9`PI8TY$>Shf80s}jR6NrOt`H> zb(^h&4-fT{$P3KwD%q@hkYa9HZ4BW|DmBJ~Wl6DcNf}!q>{1I&92;uEfe=`d1NH+# zN1nz(<rAh1%p!?S>`4Nxk|((joQdV;foB^Szf~e<&)spZlh`&F)2}7d_|NPyX10)B zwhJI~;$-%C$A$&L<mMMZIeDMcN{~D5GZ7Gp!2M-eJd)g<r-&~DdjMx*i>Tq+SUEeE zdk|!Ekz+1pB$gKPY~TPQ1XyzMxP<f(G!jgn!ZAKys*}^tKyAW!Ay@8a>NZ%_k_ZW- zuzXf?RW;=s@;)1|mn?P%aZ!nbb!<Z4YHwqkS^8m7Q8^NF!ug4kNTkEh-q{tcQgb=V ziY5Lj#w_3h3hp*G0U#hC+rOX<lS}Xy08{zTJnba<WYwDR5;Qnm3^I2bP^`kp2eWP5 z7b}=QdF4{+Cx>Q@6*-g207lN0637t-33vypW3I^}>9Rmv2ot!<bTeEMf6WG{P~e@5 zl_u?sKIV+HIN_RDQa=IGCK2yYAgVme|CFnUGbLx`1<2{R>j!Aac5mK>XvjCtVi8l$ z|HQzutg?gW%tj3*qf9fSm)6BCrk>4BV5cY54%l*ZBlArqMC6IJ^)LF{f9yo;<SY*J zz7)A|F4TgYFV@YaP9>A@Dl-aoF#s>e0%nnS@j-rWdsuDucxNLC9VezKa0{Vxu;<uV zE*%4Ca8{aN91_$4*Zj|dKZadYa9g?Fsl)@w6GuqmL2#+<vw5+<Q-F#8<+G3rK#OG% zJQ6Uoq?#I_YWV^0!x~KDHdHiAVG4l~mDn?A2$P@7Ac|tFx$FE^utXuY9*^y!fGpe4 zo=NP2eB+KVr^J?ro%A_k_t_bpi(p-8=8|2&h6`mRjkk1!hb<KQ#yqv&P(YxaQUr0T zJVA+p0o)+F_p?AX<_7x23)N#;gSpis^fc_u1xVhNb}&Q2MnJuowX+@Y;lw)+-kN7R zK{ODih?t$@WoAu>8O@6KUZC?GXq=&>WST7TCXV2tHw5$0qREZM2GD!Q(}XDd$T2EW zaQqNmp^&bHq&}2eD{f=~3r>~Qb#@iGv(C}PymP0COhDl-@oXZ{qI6EUQgpT5pdcuc z+c`iyd7uo?ET}UjdpXRkd#rF$GbuLpfM91;bv{(CV$wenZP0nKALU5Fv;dm~8`O|* zp2753U%oXp=2mjtPOR-~Z25LbFriGTqPL>2cgetI^rWY3u|mFF?NXkeAFndGf)R~! zNx`e?94V1ILf7H-u`C0(7{53$4mY(g*9~qpgfcPpXrfTOEH(4y$T;^5Z^C;i8cqhJ zy%J~#<!#xn9Y#-t1%fqqfYHRe1cU_-lz=kVyOXM8y+OdT<>Z4|-=Pi2E)WmGl8%!` zRatj;$*g5V%+#gj#tF4w1WV4%PM5Y0jsg)p#|-xENZwkaeNbO-<sl1=W9=LIPkK4! zyID<?y;aKjB6Tr8gj+Y%+oEd2>R+m$1*)G*2C8!>Wt+6O2`Kwr08gb+>I7&Tfn?Q( zxi2+zIFNAdfvk2SHAoSQvbEIRAqKBF&O8<3MU{+rmg#f*=h+sbeVtJG1G-kh0cG)} z(X2e?a^R~#ynsPy@2jOe8Y?%wlun4HpeZM}IhB!b11BqY!6yvoDr%fGMpy}wC>51* zOv_iRVhG7GyGx;PXma`<xE|QjIg7dEOLv^~p=woAF?tP|IQ*tYLj!2P0y#PbhgFIx z?tt2Yw?}2fv18hE8)`yP)(uO1pcPBnPMSKK+6CyJo7cuottS?17qS(^Sd1U<%t<E& zt8VXfG$`O65-@ofcHlxWq->meBP^n%!33&j)n;vkRRNR8cL<9(dGy09SKtVAizdi& zQ3puZni{chA!)-($X`Qsyssq_);1CFgRYoZjUUePf;NlFXhMLom!tmxZ1ZUFO&%=Y z)sC2A?NY`H!Hceg7@cPwYq20^N=!yR<+{TH%>@eQP2F9M-6)*|#k{^kN^|R1z%BVi zJAQvk;pkz^Y+`5*$Gl{2ws7IsgQJz#?q(@bmjJMWlSo&Lz*Xu-n{k19El^Co#3Nc| zno5o+UXNZ_n$mGnu&j42r0I}#7%*#Tfm}s$x>^-!DewAOTIjJdAmAXE*h??tF|*fK z$(Ss3dnvP~_@(MbRPzQ&h$l-_;Nx-ks7r7U?VmOqA&5;`*qUq6JlFTt6jHFS2*?eW z-K>KSgb^<h>sm^+LnCvUw@qglvwp~{+5m1q^wT`rwsIj$)eb654a_VQ%<I1kz;Lmz z3C_sgC~Xd%MX*e^A*k5ES{0I@ML`e;$Yrt+6?<rf$Nu=2N>MBRXrDoSJfoIXxw*C$ zrLMrxI+*Ro<;h~Bi3f)Vqg&Y#4MO&={~4d!v{-Ya^HtLI23*kCY-2g}YRj&2YC|EG z@66ib-A9Q&je=7pd4HdPF?1okHP^Uw_j8j9bQvU(5Z+G^n5}RLNFfKS%}Nu*<K?Ai zbum-md6rlwD%tz9$4fbxO^YL0M6w!Fn`;B|*2!P){HKe899^N*#5}0~!uW&b62(@U z1c<hkf?oRsniV?U7!<Hye;<&5rBxd1)Bmats_zhXDm4(DkU`-4ToMo0L<AI<(7psU zCaR39mYwi{qhe5Jvk!Etd!}-dT1W^E3=|?FOHDpBP+qHb!FFo+3|6{tZCHxVyX;cp zSDjz_PY-!*VFL}}lm@uxv+E6uvFW2}Fl#3&CQ<2D6GZ4s;QT!1QH2e(u91vN)Rt%y zG7(Bk9<>lZrnu4G*{~Ubvuo=ueNnpx;$3o&b-6@@m99uzyl`fhop&3Q*tWGe)7}!c zvpYg9bBFd90+Gd{K~K;-!%>x}((mqQtKS`F#t{Yeaa<xF;q4N~fGs^6%8Xq?RojbR zo024Mm;c-5NC4>qacEayEp||MzA801Z?uI(B8<|kCny38QIX4BY6kP#m`tDovFRuX zZ-)*Ns?&{(wmDWR16z_O+)6ybExFCTT;kroj_=Qxpw1Y!Jdf!`G|$RMP)o-Snj>-n zHen!*NHzky#GDr9ybzfv2;&Ny_9+0TX46n5D`>UaE`_q48V!@Wvr5<yVU-k|9g-|A zh=cpBQ}d}BX1O_o7V#Bxol3oxBk2-eI_4l1Oq55D(eO(An)shhR%d9<G$vmKP1{*k ztP(sl|Gu}{s~{nk4r31<yq4M$QCo)Q<~8@G@>F(G$#6g(^6N#wanZ4;2ypnP+`Xc- zXN2IQ?Hn{10DyO>(hO%)$`b>W?OkQN_CaGumy$wBY(0g-Ng0#96TbJV>3qBTTmA!m zi$9U%Z3(UNla3t;%)+ZVr6{CA9}>@n5gaXaSBR(7IXI+u2RjQU?H+F&FqW8o23RPx z^yvowi{YTOpzM`=5kjK1YObo@u6YYjZSRn@`dnf&3NW9QJF6)o;gai!laNeU$$@Lw zfWdvg8&qc_+eSWlN!bg7xzv#h=b<HB^#=oTcAaHPAsCPJM-kCZF)|I!if7Qy7ObaA z5=9a{YK#*yQIBGXE|3jWxmTW-&E8wMm7@ngcF~_`iWmfK1KE{tml|jtwn`p!sM?U{ zP#Pq28!q|~3!El8O*%ApAr==OVmciVeiyt8=HJ?RbK@jf#DqHx-*^Kn#%&4fkQ0JF zCQTHlq9OEwqKGb)B6u1wpB7DVPO`99WuXhOb<uI!Fw}nM7R<&%X@%XMr4F^5?kZ(R z-h|UWWkWWloV)`y-;>i;c1!iaw~*5)fkEhin8$f;_*=DXa`LJ3knL{Crh6=FRf<#z z64BtU+8HtbCgv*NfZC)CqCZlaAQ|B^Z-C$96E!##*APo*8cCEb2#F^}+Ukv-UgM7X z$Li@*o<7MRrdI8k^0{2pN`;`l1SB!LTAF+HB2)~@6iu_-$R(B1D@{wak?KAzTior6 zTui8#h)NPB)INE0UaK-!cL358$<B6i^GBJL)H<mKC<wLklk;#f#B-%O<MBsnXR#Yc zO(#iKQ273|@*o`qiPUANKi$do?w`$9Vc?}=Tq?Wp^{@ryV{(e*P`Sgb<76$`s6fF% zdL&2}#1q%sxmo@aGf>XXgkXFzt3F9flvjy3Lrp8$3lm8cq7(tlM*g$3&A&_)LKUc2 z{XlsdzthuHv#iXsR8y&frK*Wl{MGVR2J77xg*ExyPOFO3e!5B`A6^pQb62Fi#ieLX z-4)Wvt!*c;2G_CTGbF2+5NJjhoN`1#l=}-tyOt8vkfIXMUeHXzS7IEw*{ShKbzoug zJgi7%zh9-(CZ+b?E|V^`Fqdeh3nzMDH_xg^%dRJs=Weup4@3tU*i!av-+H^y``M0r zrGLca8~r8VKv&wD_+qk`mIb}?RarP>h>kt96@)<KCgg;GRk~12?7$L{d+a9vxgce{ zNrN|=mIXoXN%cWq7He;yJJG3S=13dbL@sr6VCHbRxUv}YT-r6pUGJ}GPnkbeN=sR{ z9yjwHNT{IobXg7S)*K&0v8yVp_T6!9eYgcxlqW&NYdLPT&~8Mn48%}iw>JsTVjPLR zaC10xfV1@?qz5VKvb9j5GutY=)P6p;3I?jPT>uDBV#3@?6bM_iAYE6Y>QUWH3u2$8 z>Nuq!Vv=0^tWb&MFR5XxL^9u`k95ML=#28^Tj9^XS4ekg_4CEL&{{zo^rQRZ5zZ>; z==@5SUi-a6Xg<sXS@os7)>ji8F%`F*kV2X=>cW7X>Op9HfrYZjbp=f-?Q9CKjUsPr zV?I}?8qu;rr7_wSo6vsaQNk@ZL}$6RLnPMa4#;|!?&l%y9dnxz?Q-lT-|)ys2}T^| zW(Y#g=2wYTBppa}qI(^@j$SZV>1bPP;aE@NaRLhhk!`I2zd_5u0t)?>8fZjp%TpmR znrLr)Jhe0?yF#%ge#Bt&IHfT41k|>ty$u@MDrFV4wx(<#`arK6hu}*%B_+YsNs>0x zhLZ3qoHbFfA%hmw4T=`CNFp|>OQfot1%j&_yUL`TAHE(VMb&0*BUjae;iOWNVUMGH z3WtY7q0#|t5Rp%JL|;|WLFoKJ8sFwp8tc+d1U9zXgwfv!B$NYKXHZ|cE@jAzdujby zYDS?15oV)Ci((RnooX!Go2biuVqvk2#w3->)V;w85N{t1*Mu||Yai+YpkLS0Gm(|i zyR}i41(=rR<;%0`v09-rI78l5@Q|%(*5qXx8qYu-dU--TYjLn*6)UrE6=+);5Mc*w z&*}|nq;(65o;oaJm3Pn}`?3&-qdv&p6fB2!&_P-;w-pbeRa}Nnx^(|QifS4>%i%`m z%5?UM#h4E^tsB{<#Rcn~ghkTJV!CJRjW0OeBK8hh?0QZ5eEb0A*FG0@+rWmJ??9Ww z&HB2@bZh5t`0QF;0>5ccpdTVh8&maPS~9d%yFMQQM&%e!B`ey5o(?S7S{*Tb>ntb= zwW^X;Wkv_5{Jid-{b|BS`-Airr|T*xthGf{(9YbluhP_RA=*@y&T0eyr|7ocAOlZ! zwnYjrUpfv;7gs3R+nTwcACGSqW<}m^WfI2RhDg&WHHN7ux!~--TQEzB@n4-J6?Sa6 z<mOankwYIqu<}Y|R7RmF39!_be7-6>DGZl0n?D;(cganrND4AGC=7!~?S$NuAdWI< zheob}CyS<@CQi`Zl~y^cB24R29*P-|ZJC_XVxO2k`mcQeV(kW`RV{lofq<@YX?mw2 zZ`nmGg}isd|9KW%+URW_eMqzlu_@ZCHGcVo&RFcAkxFYVlS;HeMy`jiTRpp6Cvsvw z?Ud(RF#(7n;;P23rEI#kEY5|Pk-}*&&47bZ7t^THERpS$I$f*LEWL~Wk;+Xek)+;~ zr0EBgkycs#3j?G*-~MXCg^J89+*#Gf=tNtybIYm;_|xj8uAh5#dn8rCP<wL@)`mt! z8BRcE3W#dr=ti7U{7kcU#OuVkJ42~Mj?Od4!(@Czj@-d)YY9IpXYt~iNX1s#f1Glo zS)>0v3JcMDWrNyJ0mCE&Ei0uWN7ytY7ZF@HrpiG5Hk}gzr#*+Y`Z{&k)H^|M>MP&f zn&WPdsG!xMgqvERJ9@q%oB1qH!vw8`Zb$cXDJ1n~7;S=b5haI=zanVO(cHrDQI7#_ zG)J~d7O@x|YQ!k{KB_*mgj;)da&F;Yse%e04zPBZRS;e9Y{{wB%o5}DVQ|#dm?A@@ z{|Vk=(y=N%&Qlw5GO|TLjv}JS(?@OzL*A(BR0<?QY2D|3+$kv|L6{w*k){d&hviWM zMzym79ESwIo=T*dXvnOCZU<#Cb(ai71k?c&O9PLPj!S0kQC*cb>0ezUu3JU<Rfd!A z?1aK)a&J~=T-aZjT*z(%0e_-@OFpz1UO<4#*|9ez23A#92&olpgpp{w6c0k`zvIDi zvZLYy-R(;O5%VWj?7-$IF+(IT{>2*bu`HJ$(3c>XtG&C&A=}(s)(#b#vsu=!s+o-Z z>2Vm=Bt^ANqPpQX<q~IU^O+18E3pz*tEk(kIBOZWw`39UQ!C-@xQ)tpT5dsuR_p2l zbUn+`@xRiQv_9fEp~=yzdbHE1hc>req^h{8w%Xw=kynD=`#V&0MHt&!fP}m{iHyJv zgRKjK97scTqRWp$cd@BGL_Lbxppig6b*Nbx!PqWU*<?g%>$nmWs$D>rCm{nyXG>X# zT3|;?P+S35t=ko4Yey4ji6wbbiB{Q!p0s{iC(X3qW0*9V^W42!%c>z*7zB+(M_%>3 zv|A3*p)XPg5T{f%OrMPyIvbMlMAeDu7yC@ScQ-fDYL0DbbYMz5)RCw4r3=|4$q^{G z8ZA2wR#0;qfQn6++Asi#uWi<03t-aKAs~y!Fw4`Uzv%ph>viv_Yh|6x(Qs8@)2*zb z+8~<RTbBeUmvu2hxZFxzv1MPHxy`SoqF{ARN*V-HQ+3Ij`R=J}`N_r`%N`n#MvEwQ zItO7@6sKB(c(38U)oNQ6Nx(|QU|01<=sm!Iz<zU+>@f*}=5)VXPGvg`NKTbtYhu7I zl#|PRkB}_4@_W69+g6$cyJ_6@s<0DJZj!pRsJS2m6eNzcwM6o`nZdOse)aaYwA+`> z*L3JNqsZ&v_t+1`(?COj4|>9;iNzMI&qRNUN?&PdX(!KCpZRMHz*whV>n-lfx-1oN z8dS@Lrw+^JfjjzcT<IXwk)jZrbq&JxgW5yy%bd~N8kq#MI(Xcok&@97tlcwen@vOo z$KA`gs@^~r>#ig3^|XsM7R3_Ec{9n6vAfDcQy*7UJjiQwG>dgWJoNyf+uWhN3OGxS zn(vsgaMW3h-YCq5nWNfB60Vj5XM;ykUz&`;W8IyAL_dyp-SR34`sxT9nntlcFZVpJ zoH=PjfPYuZXse;;v$e&(!ZvM=>GRnU8aRakN>8HQYeHvR&IK!$;3WS&Dq!X$d>eli z?9tIuy%dX$vRn~8qoct=%$;1)Wna28BuJB#o~%O5uPFgcI!}OhN$wI_?JN|bafYor zI+tbL=r1O;oPj8y>6k00pV7$1TTgj;@4j{<@i5%E6_L$oy9yXbdoxuMm0xBSm`aBk zR5-Sl%oHuDme0<B07Dh2cdn%pegse3(}a_nUG?(2^St%>v5>^|h}z}m>pO%_3WIGn zBT=EVwyCy*S2VAL)-pCLdDmf@7u|t6J<-Bso~YH$IRdWJ%ChQjB4^|cT?##m;!mwg z4~f+_o2S~)Zzxp(w^U^ij7cTa@kwLiByNZ^gD}ON*e3u%)TKYsv|tw?%G&cAR3GTc zqQ@2{o2lNZ1C$0SHnyWVeF?Ue$qi-t@svf>7^;-t7t}Z^zn2C`N@AWf3~73x4OVTB zxr0sYl5=S64qYPB80DI&kGr2@ozGGXSuW$K#_p5=hpMaNvB;3PZJDgO(%e}?j4pcD zz&67Ii``=sYWvPU6>1QsSm^c>^dkt)6zbV2a!lSi_CBn<th1-A1$}v}RC>>^?rnN& zMVu^AQMI=LGF70mcP3#ijdIbjD?ciEIL@c7Kcj2S1w994;bZ1Qfgq}k0B%Ag9ovi7 zm~Ya=!uZsaIH)L2<4qA~d{+*DJCO`q&jy$(!LOK{V&E*TD)i4qjy=_)GH5Lrk&azS z+;rOqkZ2MCyXJfj6CIKz%r8lMbh78QD9fNaMb30LtR1XU2xYZ;;D(XVTUxBFwxz@c zrP0ZL68g^a(Zbtxl)_W<a%@wO)yElOpARyTp5}rTHHV1Qo2zW^h@ot1HiP$b+o>gs z$p`&Xa}f<bB#5XX{ZCyQ!A_?d8wQ5=<P52|rNJ&{%Zro`4RlDH4j}AUFOodYNAK8K zUk#O#+)6WjJ*6xO7kbfsRd%!YK!(aG6uAx@sp(!*hwk+1_4-t&HE+|q`KJ!kXhk<U zDMOy$)g)*6i=%`!GNmv^B0ul>P31y@zHX7MT58nc4kpt(RxNK)M60UA->KSyo<ien zg|)-*Kmb(%NrnarqJqA7puOoiMzz{0HuM%}sm)YCGO)9L<`z;%*KW6&Q{~kZfvT!y zl*p6-$9<T|)K4C5nYOAu@GoUcXl5`3Dg!%!S(%QWh(eV;I%wjo7~?Bo+&WipUHQ54 zTlV*_$v)%s6x3=q6*2wArOZRCyC4RdR?o!aT1~s8E0=<B1I<efYBbrA5GdFZru@vL z*l4Y3Hz<=X#=PmvnjcUq&rPU+lyeO%S-U!BIVZJ%n>2yL2d|^2Bh4jC6e;W=pIiv= zq0f8HPbpaq+tK0JN;fsj2-h!3iF!iMVyS*w?f^zRTcAn<yJ&y;PqlpH%!&evBr>ZC zT<97J`-~td{HAg+e6t)lRcpm_lmXYxoElg56ve;psfxhPGED0|;I`fKR-{xD&Kv@B zYD-6XpdWus^%zK`F`(kujZG@LM+5skhjBWp#k?LKtBkN|<tnMciH<EOq>!GiROkfd znL|^}gfP-edu1&xfl+bXlf>?10L2V`Q16jG&S2DDDp)^S4ZJnuy8{|q+Gb6J%3Sz4 z`g<u|tm6s`YPz*R=^-1mQ$RHuAR7>;KKLI($;|g?j_UC#N1Nn|Gb-#3iy9i)ZxO1d zLni?CZn~)qf&vj>?R*#g0*0|%zm97m;^?pwJJ@v^=xG#Yn!5=X9d~e+jZ_CZ-_`Zv zUW#YpT|Jef$N1=x7_i$b;(^Gg4usJtb1-5uOyySPfyP>ryduB7NK^kP8+R|rpb<su zvcZO~5MDYv;-^VgX1w>D27~Bl#}s9~`JT_!pR`VH-P?|}<75aoL55mb2YOgfavURL zW{*e!%~i=(>XmE{A+%L)yJ*}4X!=C+d<&L(R)z*1%n)xjon9`R=+)OxeA-aTW(ci9 zqpOtms%h$$k21|Buz-GO0L5=EX6*?ZM}4SWMZDU57?A|T(lp974iO8|m<lI`abeAn zPt+E3wN&t?P35xkst9<N%P6Z`l?Jh!9R{^ci*m@V{g9RDH*RdI-<dOK&k_RjtNUps zgAvBsGOIGDt5bgR4w{ltiA$xVE%R7A^f=$M$%$G+CNWqH&f!`##HYs7Hjl3!)-V@B z!PVL=6kWFRf?&14j%r6aEn<`IW@+2_?4fXD^yq+-LC|p-bl9s@qJUlIyLK3b{LE*% zk1grUoUF9sB9-qI`;}!FP(g0b09U715GiH)w5hL(XB%$rEkWw2Ca}tqKF?Y1Cd^*7 zbF(Z#BU0~b7YpM_a93i&aTkuWa?s9J!K0G969;pfVp7)TMRkf}j)+Hz(`iH1h?_G~ z#@Q*)MKRbpmlN%%>8p*VOHxr08j<9{#P`_)1;{<6f48n($$ibTZn$Mi`Sz90o;YPi zh_Ws0R%Nmd*-@FBL+q|LeH5@uJ4R~01f8=I)Q)qv$1S|b>ly(i#s$Nke&;A1gqOL2 zvnNZym}&vTU<1=jr6%#?^UXe}6%n_(VAFmB$<_FHPfDZ=+8eT@&<h*(bW9BfF(_Ug zqrr=-M?Y*mvg7EGY)8-L;`OC7dCs;tu~=G-jYst4(An7n4*(I?oR3%8yLPfduLrhN zrZyuVjPtMU_OST1qbw6N*wbogNOcdOy2J2@16giSlf;vi>H%-JEju5ENt+zd<|+4# zC^FPbzyY3M*0r8xtR3UPB_t_GMN;ko1qN}<mFaCBPa(&K+Z!#5IwFT*Q6H{qR&^Jt z3ygb=PQp5h&jz#HI}@%q1|?Skam>rW7WiS(dEss0%1h^ai63wAUp%h!_*V~3>k)-p zXY+dO%-&|vsfk4|>}nzy%UUdq*bZF<OVL!UXs%g)UxmezmWo=Xf+gGx9AeguW{m33 zZ*k|=(b?i()l;C%fSBl%Oh~Nv++nGf`zRKgXgrqvsFuFd%$*os$dYH2?KBDxaOtW& zXApH7$nlS8vl{f(gGG9Zkq1YPs{E=|QQ$hZ53GQ!k6WE(R{_~}woEyrbD`zxk~&8! z;YvMwwF?v307|+?Jsn&7jlc=v(b{wN6av-?)r~ytF&~;CHiJsGV`8_y@G4c*;&uoy z4kV*+ZA0^{=BULxsoj0r6VKjnX+-7eow(~hIx#f&qPR+UlTb%>lLdpE;OvCSTtXHL zV=zYm^_JoA4sC;CRI~bEC&g`b(rbxFvjn3JCEe7kJzR^iR{=f@T^&736H`i{ZV}13 zj$41H7S$_O8sYZtSKXw#Llw|N4s2jg1zAh!IE`~_XA5N4(i}LBtG7re?6eIVQW3*t zIpJ=(=w^tGZ&nRo#<p>GX_A_y5u&j}<GEdD%~{eH`Iy=Q^{g+ac?b$r>{T_Ja&8y6 z9L?!m80Gs>Z)7HhTyRjsWa~AxcHg?UT^t8Hndxxu1%8q+<v7cmqJon5dPZGm#-%V= zNFDFC$hX`1($?)5#npp#jI<z>;0y<~!b~Pf9h*dYvpH<Rtl(I0YR5qZl?sdstc+>) zd<}fGF(2Is(-Qh_)|vXoi1O1B{T_wdgGQ^8GX<yJ<&YZ<Fyte%m^+ZdxAAByz*9=Z zjS6;7zFdp_$rZ@zsCbSlp>Mts6fr7$wog$;pL}C#y$)z~o_X%MphlTJXU`fPH$}`! z@!Mp#WC`Owf~ZIN^|-CQ$Dv+TK{@|VkhpG*VK-}3Vs5e<Znki$hP_0!IgJzfZ>-CC zno5azsw_#waFP*iRZk~G9$al;V=F031mZ4|KFy%VS7rfoyo2g&tM*cU<+RQcBR3eB zD$Tu~%m-Gj)$>UENEAYn(YZvH)^iPetixRStiIn;`QPXaB_dx!?R=Dj1Zco7Ifo{0 zw2H!(bxwZkc`x>tY6m+YyIi-lvxiMhEso&H(!vh^>6w!n)&wUQp%~NL`Lv^w2nCz+ zrNg|Eu_J9-ezcm@W89r-K+a?dD!`wZIBatCWG&CWOf8q8l>3~sy{b=VyPd7%)FN#~ zD-U(M49_#A#c^13#~hoq0BuULwUoNU4lhi%rrzB1+MI}7sBZWa>o6?P+Edf^vfJ~m z1v6T(HTGzYw4u~;!NHX{0pm7Tr=jPg2k4e_+govU0XV4!D-bmIXb4txH5-^nx%M)i z_^6&Yc~&;kO&A=thm#RAoE5-A_3J$;t!d}1YJ}rdpB+7yz|nVx{Cg;rg9Gc@_ql^* zTPg2!Q1|=P)4fB$W^<3xldV)ZUPL<(7;Ugjp3EmCTsXraL!%r4giYkbM=(A5rj#yA z2|>i~QdH%9O|^}{X`PM9JK=$VR`wHxxewr97d9{`N*j*cDwlGsoU`OS>8v5Xjh^lS z5IN8r^uS5?G@1J}AABBJnM3@hPMtcqOtGY2)I(pY(C(B_Pp{%Gn7Ycs)oyq!yzA0= zldUtNB(g^dl)XAEw4ie!4YpucG%A<AV$fIcz3z!Yg#i5_VpzlO9>d0W+v>gYP6etY z-cDN&9lrZ?BDh&ZF=M}{6Zalma(1xFM6&7X))im|>c5?axf6_t8Vxk6qn_QUy)t*? z(clx6-BQ+5S=@OEfU_r{sFF+;o5a6oJ<g6R2{XQ~ol8h(sY-RKSU~08LA`}}pY78* zNaJX_q3?p}_1ejjDB&@|S_x}U`ZNu^^u!L$!TVS<)C;{TYdLy~bPob8=>fjUy{F^S zirj>Qy=N2MdVC%7o%9|<WK2m523kg-G&kI%U>HG3v4hhCW;(iQQ%4TYqR**esmBJQ zU7TwqZ8#hQPMdm&74k;&9TC?CCB9+5s%I%Ps|Z)Xv?No|xWOJK)iX#+aWr_HcNOkL zdlk7F#c&+E24;7CgCZvKAmA-g6_&o*rPS3p3cHR9!A$~RJs=5AXcgxSO#Kt8S}4jY z8D~8z4!b(;C;wU`c;8sxS>3hsz82?Z>xSsooK*$69SOa~?Rg7*o4QGY=lkda=Q?yK z6bwz$gIBe;2^R=sorb0)F)c)v+p{HvD;4#0o2F)7#}HJsr-QJKc~oMA1K)biqgIeU z&f<x1F!f_iqpB>h&-0x&=N{fxDrN22xlV=GNES%+ASq@#9?>K1k%EYg9s}J0P&EQT z><k5Nqo3MiA<rHyf*qU-p?fI@321(R3h<OMN>h89i8{`Nbd`i7EYYVOUNT0_7mj<D zk0hd4iGWvsS)O#7n*M+L@ZynShNaM5LxE3kW$p>0ouWMBBtX^zZ|7h-VZr^~jcP%# zhdV5{xY@M$+Tn-xM~>3zH*u!VT>%Oqnd9Uf>e-A-%guw}DXnYUOCmP)WRSKH{6A>u zY4{yM-|y2{ub!kLVfP%PW4mPs?H?Q+;-qC;uvze3MaM^v8@-P&CkO*dwvLpcZaXi+ z6W2}wsrM!8ssAq<p2pFtO$?WqlYmE|-L3zB7uFu8LiXlNbc1mARozoHBD6z~B>Pcn zjvf_3vZlK_v?m#oev(dhH7)I*cMOWwxueEC)2auYw+7NXz2r|th%<F_5BG%iUV2+< zKS76kYIeJWsTsu{vfu=kt%7Hek0(3N<itJVgUzP)T}O|aDmzmt7$rTjPRde5;!b*g zZr0bC>xK*!;c8POvYvRmPhMUep#*c%<JJDMZ9VQx+d}aIn<xMr@T2XI<i=3Y7E;JM z<k67A(gQUoGZg0ZC6~4M)%=*f-H-rOo$$z34Mvat=_#x|(T3048<?1^-b0+7$vbJ| zRd+q=(a;W#olv$^qFNi|A61e%cX|5o&xe0L{PW?T5C44l=fgk$pZ|H!|G%;?yzt87 zA9?u7OHW?<%xiDH`MKx*+^es@{^oNJAHVXs=ko98UVP!@AAa)W%{ThO%TL~zpL_8K eUVY)S_lxiU<?`NNel}Nr@qYsh|L5gga{vG<RF+Ku diff --git a/tests/stubs/macro.txt b/tests/stubs/macro.txt new file mode 100644 index 00000000..e9dbb056 --- /dev/null +++ b/tests/stubs/macro.txt @@ -0,0 +1,10 @@ +(define-macro (defstruct name . fields) + "First Line." "word" 10 + "Second Line." "word" #/regex/ + "Third Line." "word" + 10 10+10i +inf.0 +inf.0+inf.0i +nan.0 +nan.0+nan.0i + 1/2+1/2i 10.10+1/2i 1/2+10.0i + (let ((names (map (lambda (symbol) (gensym)) fields)) + (struct (gensym)) + (field-arg (gensym))) + From df23d954e272b794f73c708e69caee1e46d8aed2 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 28 Feb 2021 17:30:45 +0100 Subject: [PATCH 056/109] basic input-bytevector #132 --- README.md | 4 +-- dist/lips.js | 69 ++++++++++++++++++++++++++++++++++++++++++++--- dist/lips.min.js | 4 +-- dist/std.min.scm | 12 ++++++++- dist/std.scm | 67 ++++++++++++++++++++++++++++++++++++++++----- lib/R7RS.scm | 53 ++++++++++++++++++++++++++++++++++++ lib/bootstrap.scm | 14 +++++----- src/lips.js | 60 +++++++++++++++++++++++++++++++++++++++++ tests/ports.scm | 19 +++++++++++++ 9 files changed, 281 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ebfc8494..1d8b5dc6 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&eb1ec20f19611017e2f2878a33d61601e77a1568)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&388ce272c1300b132657adb1d2190a85)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&2580adf9a4633a1263a0915305033bb254045fcb)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&73fdd331a2b532845b0f720c2d24e906)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 77eda81d..bd3f1fb9 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 14:26:21 +0000 + * build: Sun, 28 Feb 2021 16:26:26 +0000 */ (function () { 'use strict'; @@ -8987,6 +8987,63 @@ }; // ------------------------------------------------------------------------- + function InputByteVectorPort(bytevectors) { + if (typeof this !== 'undefined' && !(this instanceof InputByteVectorPort) || typeof this === 'undefined') { + return new InputByteVectorPort(bytevectors); + } + + typecheck('InputByteVectorPort', bytevectors, 'uint8array'); + Object.defineProperty(this, '_vector', { + enumerable: true, + value: bytevectors + }); // TODO: Consider _index read/write typechecked property + + this._index = 0; + } + + InputByteVectorPort.prototype = Object.create(InputPort.prototype); + InputByteVectorPort.prototype.constructor = InputByteVectorPort; + + InputByteVectorPort.prototype.toString = function () { + return "#<input-port <bytevector>>"; + }; + + 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 _byte = this.peek_u8(); + + this.skip(); + return _byte; + }; + + InputByteVectorPort.prototype.read_u8_vector = function (len) { + if (typeof len === 'undefined') { + len = this._vector.length; + } else if (len > this._index + this._vector.length) { + len = this._index + this._vector.length; + } + + if (this.peek() === eof) { + return eof; + } + + return this._vector.slice(this._index, len); + }; // ------------------------------------------------------------------------- + + function InputFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || typeof this === 'undefined') { return new InputFilePort(content, filename); @@ -8994,6 +9051,9 @@ InputStringPort.call(this, content); typecheck('InputFilePort', filename, 'string'); + Object.defineProperty(this, '_text', { + value: true + }); this.__filename__ = filename; } @@ -13319,10 +13379,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 28 Feb 2021 14:26:21 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 28 Feb 2021 16:26:26 +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('Sun, 28 Feb 2021 14:26:21 +0000').valueOf(); + var date = LString('Sun, 28 Feb 2021 16:26:26 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13362,7 +13422,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 28 Feb 2021 14:26:21 +0000', + date: 'Sun, 28 Feb 2021 16:26:26 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), @@ -13388,6 +13448,7 @@ OutputFilePort: OutputFilePort, InputStringPort: InputStringPort, OutputStringPort: OutputStringPort, + InputByteVectorPort: InputByteVectorPort, Formatter: Formatter, Parser: Parser, Lexer: Lexer, diff --git a/dist/lips.min.js b/dist/lips.min.js index 806eddb2..4e3fcc49 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 14:26:21 +0000 + * build: Sun, 28 Feb 2021 16:26:26 +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(n){function t(e,r){n.exports=t=Object.setPrototypeOf||function e(r,n){r.__proto__=n;return r};return t(e,r)}n.exports=t});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(t){function i(e,r,n){if(isNativeReflectConstruct()){t.exports=i=Reflect.construct}else{t.exports=i=function e(r,n,t){var i=[null];i.push.apply(i,n);var a=Function.bind.apply(r,i);var u=new a;if(t)setPrototypeOf(u,t.prototype);return u}}return i.apply(null,arguments)}t.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 n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return arrayLikeToArray(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=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 a(e,r,n){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,n){return e[r]=n}}function o(e,r,n,t){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(t||[]);a._invoke=F(e,n,u);return a}u.wrap=o;function f(e,r,n){try{return{type:"normal",arg:e.call(r,n)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var m="completed";var d={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,t,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,t,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,n,t){var i=f(o[e],o,r);if(i.type==="throw"){t(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,n,t)},function(e){s("throw",e,n,t)})}return c.resolve(u).then(function(e){a.value=e;n(a)},function(e){return s("throw",e,n,t)})}}var r;function e(n,t){function e(){return new c(function(e,r){s(n,t,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[n]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,n,t,i){if(i===void 0)i=Promise;var a=new x(o(e,r,n,t),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,n){if(s===h){throw new Error("Generator is already running")}if(s===m){if(r==="throw"){throw n}return P()}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(s===_){s=m;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?m:p;if(a.arg===d){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=m;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=f(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}L(w);a(w,t,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.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 k(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<r.length){if(l.call(r,n)){e.value=r[n];e.done=false;return e}}e.value=c;e.done=true;return e};return t.next=t}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(n){if(this.done){throw n}var t=this;function e(e,r){a.type="throw";a.arg=n;t.next=e;if(r){t.method="next";t.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var n=this.tryEntries.length-1;n>=0;--n){var t=this.tryEntries[n];if(t.tryLoc<=this.prev&&l.call(t,"finallyLoc")&&this.prev<t.finallyLoc){var i=t;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return d}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.finallyLoc===e){this.complete(n.completion,n.afterLoc);S(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;S(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){this.delegate={iterator:k(e),resultName:r,nextLoc:n};if(this.method==="next"){this.arg=c}return d}};return u}(e.exports);try{regeneratorRuntime=r}catch(e){Function("r","regeneratorRuntime = r")(r)}});var regenerator=runtime_1;function asyncGeneratorStep(e,r,n,t,i,a,u){try{var o=e[a](u);var c=o.value}catch(e){n(e);return}if(o.done){r(c)}else{Promise.resolve(c).then(t,i)}}function _asyncToGenerator(o){return function(){var e=this,u=arguments;return new Promise(function(r,n){var t=o.apply(e,u);function i(e){asyncGeneratorStep(t,r,n,i,a,"next",e)}function a(e){asyncGeneratorStep(t,r,n,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 n=0;n<r.length;n++){var t=r[n];t.enumerable=t.enumerable||false;t.configurable=true;if("value"in t)t.writable=true;Object.defineProperty(e,t.key,t)}}function _createClass(e,r,n){if(r)_defineProperties(e.prototype,r);if(n)_defineProperties(e,n);return e}var createClass=_createClass;function _defineProperty(e,r,n){if(r in e){Object.defineProperty(e,r,{value:n,enumerable:true,configurable:true,writable:true})}else{e[r]=n}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var n={};var t=Object.keys(e);var i,a;for(a=0;a<t.length;a++){i=t[a];if(r.indexOf(i)>=0)continue;n[i]=e[i]}return n}var objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose;function _objectWithoutProperties(e,r){if(e==null)return{};var n=objectWithoutPropertiesLoose(e,r);var t,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++){t=a[i];if(r.indexOf(t)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,t))continue;n[t]=e[t]}}return n}var objectWithoutProperties=_objectWithoutProperties;function _iterableToArrayLimit(e,r){if(typeof Symbol==="undefined"||!(Symbol.iterator in Object(e)))return;var n=[];var t=true;var i=false;var a=undefined;try{for(var u=e[Symbol.iterator](),o;!(t=(o=u.next()).done);t=true){n.push(o.value);if(r&&n.length===r)break}}catch(e){i=true;a=e}finally{try{if(!t&&u["return"]!=null)u["return"]()}finally{if(i)throw a}}return n}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 n(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){r.exports=n=function e(r){return typeof r}}else{r.exports=n=function e(r){return r&&typeof Symbol==="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r}}return n(e)}r.exports=n});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(t,i){return new Promise(function(e,r){var n={key:t,arg:i,resolve:e,reject:r,next:null};if(o){o=o.next=n}else{u=o=n;c(t,i)}})}function c(r,e){try{var n=a[r](e);var t=n.value;var i=t instanceof AwaitValue;Promise.resolve(i?t.wrapped:t).then(function(e){if(i){c(r==="return"?"return":"next",e);return}s(n.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 n;if(typeof Symbol==="undefined"||r[Symbol.iterator]==null){if(Array.isArray(r)||(n=_unsupportedIterableToArray$1(r))||e&&r&&typeof r.length==="number"){if(n)r=n;var t=0;var i=function e(){};return{s:i,n:function e(){if(t>=r.length)return{done:true};return{done:false,value:r[t++]}},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(){n=r[Symbol.iterator]()},n:function e(){var r=n.next();a=r.done;return r},e:function e(r){u=true;o=r},f:function e(){try{if(!a&&n["return"]!=null)n["return"]()}finally{if(u)throw o}}}}function _unsupportedIterableToArray$1(e,r){if(!e)return;if(typeof e==="string")return _arrayLikeToArray$1(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor)n=e.constructor.name;if(n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray$1(e,r)}function _arrayLikeToArray$1(e,r){if(r==null||r>e.length)r=e.length;for(var n=0,t=new Array(r);n<r;n++){t[n]=e[n]}return t}function ownKeys(r,e){var n=Object.keys(r);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(r);if(e)t=t.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});n.push.apply(n,t)}return n}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(n),true).forEach(function(e){defineProperty(r,e,n[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(n))}else{ownKeys(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))})}}return r}(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":_typeof_1(module))==="object"&&module.exports){module.exports=n(r,require("bn.js"))}else{r.lips=n(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(n,t){var i=false,e=true,a=n.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?n:a)[c](s+r.type,e,false);if(!i&&(i=true))t.call(n,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")t.call(n,"lazy");else{if(!r&&u.doScroll){try{e=!n.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);n[o](s+"load",l,false)}}function log(e){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;var t=arguments[1]===true;function r(e){if(!is_debug()){return}var r=global_env.get("repr")(e);if(n===null||n instanceof RegExp&&n.test(r)){console.log(global_env.get("type")(e)+": "+r)}if(t){console.log(e)}}if(is_promise(e)){e.then(r)}else{r(e)}return e}function is_debug(){return user_env.get("DEBUG",{throwError:false})}if(!root.fetch){root.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(o())};n.onerror=r;n.send(a.body||null);function o(){var t=[],i=[],a={},u;n.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,r,n){t.push(r=r.toLowerCase());i.push([r,n]);u=a[r];a[r]=u?"".concat(u,",").concat(n):n});return{ok:(n.status/100|0)==2,status:n.status,statusText:n.statusText,url:n.responseURL,clone:o,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}}}}})}}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 n=e==="x"?"(?!\\+|".concat(r,")"):"(?!\\.|".concat(r,")");var t="";if(e===""){t="(?:[-+]?(?:[0-9]+(?:[eE][-+]?[0-9]+)|(?:\\.[0-9]+|[0-9]+\\.[0-9]+(?![0-9]))(?:[eE][-+]?[0-9]+)?))"}return new RegExp("^((?:(?:".concat(t,"|[-+]?inf.0|[-+]?nan.0|[+-]?").concat(r,"+/").concat(r,"+(?!").concat(r,")|[+-]?").concat(r,"+)").concat(n,")?)(").concat(t,"|[-+]?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),n=r[0],t=r[1],i=r[2];a[n]=make_complex_match_re(t,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 n=0;var t=e.length;while(n<t){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<t){var a=e.charCodeAt(n++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);n--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return i(n,t)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var n={};if(r[1]){var t=r[1].replace(/#/g,"").toLowerCase().split("");if(t.includes("x")){n.radix=16}else if(t.includes("o")){n.radix=8}else if(t.includes("b")){n.radix=2}else if(t.includes("d")){n.radix=10}if(t.includes("i")){n.inexact=true}if(t.includes("e")){n.exact=true}}n.number=r[2];return n}function parse_rational(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);var t=n.number.split("/");var i=LRational({num:LNumber([t[0],n.radix||r]),denom:LNumber([t[1],n.radix||r])});if(n.inexact){return i.valueOf()}else{return i}}function parse_integer(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:10;var n=num_pre_parse(e);if(n.inexact){return LFloat(parseInt(n.number,n.radix||r))}return LNumber([n.number,n.radix||r])}function parse_character(e){var r=e.match(/#\\x([0-9a-f]+)$/i);var n;if(r){var t=parseInt(r[1],16);n=String.fromCodePoint(t)}else{r=e.match(/#\\(.+)$/);if(r){n=r[1]}}if(n){return LCharacter(n)}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 n=e.split("/");r=LRational({num:LNumber([n[0],i]),denom:LNumber([n[1],i])})}else if(e.match(float_re)){var t=parse_float(e);if(a.exact){return t.toRational()}return t}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 n;var t=a.number.match(complex_bare_match_re);if(i!==10&&t){n=t}else{n=a.number.match(complex_list_re[i])}var u,o;o=r(n[2]);if(n[1]){u=r(n[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 n=parseInt(r[4],10);var t;var i=r[1].replace(/[-+]?([0-9]*)\..+$/,"$1").length;var a=r[3]&&r[3].length;if(i<Math.abs(n)){t=LNumber([r[1].replace(/\./,""),10]);if(a){n-=a}}}return{exponent:n,mantisa:t}}function parse_float(e){var r=num_pre_parse(e);var n=parseFloat(r.number);var t=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&t){return LNumber(n)}if(is_int(n)&&r.number.match(/e\+?[0-9]/i)){return LNumber(n)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){return LNumber(a).mul(o)}}}n=LFloat(n);if(r.exact){return n.toRational()}return n}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 n={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 n[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 n=e.match(/#\\(.+)/);if(n&&ucs2decode(n[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")}}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 n=[];while(true){var t=r.peek(true);if(t===eof){break}n.push(t);r.skip()}return n}function multiline_formatter(e){var r=e.token,n=objectWithoutProperties(e,["token"]);if(r.match(/^"[\s\S]*"$/)&&r.match(/\n/)){var t=new RegExp("^ {1,"+(e.col+1)+"}","mg");r=r.replace(t,"")}return _objectSpread({token:r},n)}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"#<Thunk>"};function trampoline(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return unwind(t.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(e instanceof LString){e=e.toString()}if(r){return tokens(e)}else{var n=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(n)}}function strip_s_comments(e){var r=0;var n=null;var t=[];for(var i=0;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;n=i}else{t.push([i,i+2])}i+=1;continue}if(n!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){t.push([n,i+1]);n=null}}}e=e.slice();t.reverse();for(var u=0,o=t;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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 n=this;var t=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(Array.isArray(r)){r.forEach(function(e){return n.off(e,t)})}else if(t===null){delete this._events[r]}else{this._events=this._events.filter(function(e){return e!==t})}},on:function e(r,n){var t=this;if(Array.isArray(r)){r.forEach(function(e){return t.on(e,n)})}else if(!this._events[r]){this._events[r]=[n]}else{this._events[r].push(n)}},trigger:function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,t)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,n,t){this.trigger("append");this._specials[r]={seq:r,symbol:n,type:t}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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),n=r[0],t=r[1],i=r[2];specials.append(n,t,i)});var Lexer=function(){function p(e){var r=this;var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.whitespace,i=t===void 0?false:t;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(n){Object.defineProperty(r,n,{configurable:false,enumerable:false,get:function e(){return a[n]},set:function e(r){a[n]=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,n){this.__internal[r]=n}},{key:"token",value:function e(){var r=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;if(r){var n=this._line;if(this._whitespace&&this._token==="\n"){--n}return{token:this._token,col:this._col,offset:this._i,line:n}}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 n=this.next_token();if(n){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 n=this._i;n<r;++n){var t=this.__input__[n];if(t==="\n"){var i=this.__input__.substring(this._i,n);this._i=n+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var n=this.__input__.length;if(this._i>=n){return eof}if(r+this._i>=n){return this.read_rest()}var t=this._i+r;var i=this.__input__.substring(this._i,t);var a=i.match(/\n/g);if(a){this._line+=a.length}this._i=t;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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},t=n.prev_char,i=n["char"],a=n.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,t)){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 n=this._i,t=this.__input__.length;n<t;++n){var i=this.__input__[n];var a=this.__input__[n-1]||"";var u=this.__input__[n+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=n+1}if(this._whitespace){this._next=n+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=n+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=n+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=n+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,n){var t=Lexer.literal_rule(r,n,Lexer.boundary,/\S/);return t.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,n){var t=arguments.length>2&&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,t,i,null,null]]}var a=[];for(var u=0,o=r.length;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||t);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(n)}else if(u===o-1){c.push(n);c.push(null)}else{c.push(n);c.push(n)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var n=specials.get(r),t=n.type,i=n.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(t===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.env,t=r.meta,i=t===void 0?false:t,a=r.formatter,u=a===void 0?multiline_formatter:a;classCallCheck(this,o);if(e instanceof LString){e=e.toString()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);this.__env__=n}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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=this.__lexer__.peek(true);if(!(n===eof)){r.next=4;break}return r.abrupt("return",eof);case 4:if(!this.is_comment(n.token)){r.next=7;break}this.skip();return r.abrupt("continue",0);case 7:if(!(n.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:n=this._formatter(n);if(!this._meta){r.next=20;break}return r.abrupt("return",n);case 20:return r.abrupt("return",n.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:"special",value:function e(r){return specials.names().includes(r)}},{key:"builtin",value:function e(r){return specials.builtin.includes(r)}},{key:"read",value:function(){var e=asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.peek();case 2:n=r.sent;this.skip();return r.abrupt("return",n);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 n,t,i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:n=nil,t=n;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==="."&&n!==nil)){r.next=17;break}this.skip();r.next=14;return this.read_object();case 14:t.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(n===nil){n=a}else{t.cdr=a}t=a;case 25:r.next=1;break;case 27:return r.abrupt("return",n);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 n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.next=2;return this.read();case 2:n=r.sent;if(!(n===eof)){r.next=5;break}throw new Error("Parser: Expected token eof found");case 5:return r.abrupt("return",parse_argument(n));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:"_eval",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 n,t,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:n=r.sent;if(!(n===eof)){r.next=5;break}return r.abrupt("return",n);case 5:if(!this.special(n)){r.next=35;break}t=specials.get(n);i=this.builtin(n);this.skip();r.next=11;return this.read_object();case 11:u=r.sent;if(i){r.next=22;break}o=this.__env__.get(t.symbol);if(!(typeof o==="function")){r.next=22;break}if(!is_literal(n)){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.toArray(false)));case 21:throw new Error("Parser: Invalid parser extension "+"invocation ".concat(t.symbol));case 22:if(is_literal(n)){a=new Pair(t.symbol,new Pair(u,nil))}else{a=new Pair(t.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._eval(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(t.symbol));case 35:if(!this.is_open(n)){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(n,t){var i,a;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!t){if(global_env){t=global_env.get("**interaction-environment**",{throwError:false})}else{t=user_env}}i=new Parser(n,{env:t});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 n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:null;if(r instanceof Array){var t=r.filter(is_promise);if(t.length){return unpromise(Promise.all(r),function(e){if(Object.isFrozen(r)){Object.freeze(e)}return e},n)}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 t={};e.forEach(function(e,r){var n=i[r];t[n]=e});if(Object.isFrozen(r)){Object.freeze(t)}return t},n)}}if(is_promise(r)){var o=r.then(e);if(n===null){return o}else{return o["catch"](n)}}return e(r)}function uniterate_async(e){return _uniterate_async.apply(this,arguments)}function _uniterate_async(){_uniterate_async=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:t=[];i=true;a=false;r.prev=3;o=asyncIterator(n);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;t.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",t);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,n,t){if(typeof e!=="string"){r=arguments[0];n=arguments[1];t=arguments[2];e=null}if(n){if(t){r.__doc__=n}else{r.__doc__=trim_lines(n)}}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 n=e.length;if(r<=0){throw Error("previousSexp: Invalid argument sexp = ".concat(r))}e:while(r--&&n>=0){var t=1;while(t>0){var i=e[--n];if(!i){break e}if(i==="("||i.token==="("){t--}else if(i===")"||i.token===")"){t++}}n--}return e.slice(n+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 n=(e[r+1]||{}).token;if(n){return n.length}}}return 0}function nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(n,t){function e(){if(a<=0&&o<=0){return false}var e=n[a-1];if(!nested_pattern(e)){e=[e]}var r=n[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[t[o-1]])&&(!r||match(r,[t[o]]))}function r(){return n[a]===Symbol["for"]("symbol")&&!is_symbol_string(t[o])}function i(){var e=n[a+1];var r=t[o+1];if(e!==undefined$1&&r!==undefined$1){return f([e],[r])}}var a=0;var u={};for(var o=0;o<t.length;++o){if(typeof n[a]==="undefined"){return o}if(n[a]instanceof Pattern){var c;if(["+","*"].includes(n[a].flag)){while(o<t.length){c=f(n[a].pattern,t.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(n[a].flag==="?"){c=f(n[a].pattern,t.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(n[a]instanceof RegExp){if(!t[o].match(n[a])){return-1}}else if(lips.LString.isString(n[a])){if(n[a].valueOf()!==t[o]){return-1}}else if(_typeof_1(n[a])==="symbol"){if(n[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(t[o])){u[a]++}else if([")","]"].includes(t[o])&&!s){u[a]--}if(s){o-=1}else if(typeof n[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(n[a]instanceof Array){var l=f(n[a],t.slice(o));if(l===-1||l+o>t.length){return-1}o+=l-1;a++;continue}else{return-1}a++}if(n.length!==a){return-1}return t.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*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/],shift:{1:["&","#"]}}};Formatter.match=match;Formatter.prototype._options=function e(r){var n=Formatter.defaults;if(typeof r==="undefined"){return Object.assign({},n)}var t=r&&r.exceptions||{};var i=t.specials||[];var a=t.shift||{1:[]};return _objectSpread(_objectSpread(_objectSpread({},n),r),{},{exceptions:{specials:[].concat(toConsumableArray(n.exceptions.specials),toConsumableArray(i)),shift:_objectSpread(_objectSpread({},a),{},{1:[].concat(toConsumableArray(n.exceptions.shift[1]),toConsumableArray(a[1]))})}})};Formatter.prototype.indent=function e(r){var n=tokenize(this.__code__,true);return this._indent(n,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 n=_createForOfIteratorHelper(r),t;try{for(n.s();!(t=n.n()).done;){var i=t.value;if(a.match(i)){return true}}}catch(e){n.e(e)}finally{n.f()}}return false}if(r(e.exceptions.specials)){return e.indent}var n=e.exceptions.shift;for(var t=0,i=Object.entries(n);t<i.length;t++){var u=slicedToArray(i[t],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,n){var t=this._options(n);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+t.indent}if(a&&a.length){if(a[0].line>0){t.offset=0}if(a.toString()===r.toString()&&balanced(a)){return t.offset+a[0].col}else if(a.length===1){return t.offset+a[0].col+1}else{var c=-1;if(u){var s=Formatter.exception_shift(u.token,t);if(s!==-1){c=s}}if(c===-1){c=Formatter.exception_shift(a[1].token,t)}if(c!==-1){return t.offset+a[0].col+c}else if(a[0].line<a[1].line){return t.offset+a[0].col+1}else if(a.length>3&&a[1].line===a[3].line){if(a[1].token==="("||a[1].token==="["){return t.offset+a[1].col}return t.offset+a[3].col}else if(a[0].line===a[1].line){return t.offset+t.indent+a[0].col}else{var l=a.slice(2);for(var f=0;f<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+t.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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),n=0;n<e;n++){r[n]=arguments[n]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var n=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var t=Formatter.rules;for(var i=1;i<n.length;++i){if(!n[i].trim()){continue}var a=n.slice(0,i);var u={};t.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!u[e]){u[e]=previousSexp(a,e)}});var o=_createForOfIteratorHelper(t),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=match(l,u[f].filter(function(e){return e.trim()}));var h=n.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){n.splice(i,0,"\n");i++;continue}}}catch(e){o.e(e)}finally{o.f()}}this.__code__=n.join("");return this};Formatter.prototype._spaces=function(e){return new Array(e+1).join(" ")};Formatter.prototype.format=function e(r){var n=this.__code__.replace(/[ \t]*\n[ \t]*/g,"\n ");var t=tokenize(n,true);var i=this._options(r);var a=0;var u=0;for(var o=0;o<t.length;++o){var c=t[o];if(c.token==="\n"){a=this._indent(t.slice(0,o),i);u+=a;if(t[o+1]){t[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<t.length;++s){t[s].offset+=u;t[s].col+=a;if(t[s].token==="\n"){o=s-1;break}}}}}return t.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var n=e.token.split("\n");e.token=[n[0]].concat(n.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var n=Object.prototype.toString;var t="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(n.call(u)===t){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var n=[];var t=r;while(true){if(t instanceof Pair){if(t.haveCycles("cdr")){break}var i=t.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}n.push(i);t=t.cdr}else if(t===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return n}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var n=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:true;var t=new Map;function i(e){if(e instanceof Pair){if(t.has(e)){return t.get(e)}var r=new Pair;t.set(e,r);if(n){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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}return r};Pair.fromArray=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:true;var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:false;if(e instanceof Pair||n&&e instanceof Array&&e[__data__]){return e}if(r===false){var t=nil;for(var i=e.length;i--;){t=new Pair(e[i],t)}return t}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,n)}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.toObject=function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:false;var r=this;var n={};while(true){if(r instanceof Pair&&r.car instanceof Pair){var t=r.car;var i=t.car;if(i instanceof LSymbol){i=i.__name__}if(i instanceof LString){i=i.valueOf()}var a=t.cdr;if(a instanceof Pair){a=a.toObject(e)}if(is_native(a)){if(!e){a=a.valueOf()}}n[i]=a;r=r.cdr}else{break}}return n};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 n=nil;while(true){if(r!==nil){n=e(n,r.car);r=r.cdr}else{break}}return n};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 n=e.cdr;e.cdr=r;r=e;e=n}return r};Pair.prototype.transform=function(t){function i(e){if(e instanceof Pair){if(e.replace){delete e.replace;return e}var r=t(e.car);if(r instanceof Pair){r=i(r)}var n=t(e.cdr);if(n instanceof Pair){n=i(n)}return new Pair(r,n)}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(n){var e=n.constructor||Object;var t=is_plain_object(n);var i=is_function(n[Symbol.asyncIterator])||is_function(n[Symbol.iterator]);var a;if(repr.has(e)){a=repr.get(e)}else{repr.forEach(function(e,r){r=unbind(r);if(n.constructor===r&&(r===Object&&t&&!i||r!==Object)){a=e}})}return a}var str_mapping=new Map;[[true,"#t"],[false,"#f"],[null,"null"],[undefined$1,"#<undefined>"]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];str_mapping.set(n,t)});function symbolize(n){if(n&&_typeof_1(n)==="object"){var t={};var e=Object.getOwnPropertySymbols(n);e.forEach(function(e){var r=e.toString().replace(/Symbol\(([^)]+)\)/,"$1");t[r]=toString(n[e])});var r=Object.getOwnPropertyNames(n);r.forEach(function(e){var r=n[e];if(r&&_typeof_1(r)==="object"&&r.constructor===Object){t[e]=symbolize(r)}else{t[e]=toString(r)}});return t}return n}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"#<procedure(native)>"}var r=e.prototype&&e.prototype.constructor;if(is_function(r)&&r[__lambda__]){if(e[__class__]&&r.hasOwnProperty("__name__")){var n=r.__name__;if(LString.isString(n)){n=n.toString();return"#<class:".concat(n,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var t=e.__name__;if(_typeof_1(t)==="symbol"){t=symbol_to_string(t)}if(typeof t==="string"){return"#<procedure:".concat(t,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}var instances=new Map;[[Error,function(e){return e.message}],[Pair,function(e,r){var n=r.quote,t=r.skip_cycles,i=r.pair_args;if(!t){e.markCycles()}return e.toString.apply(e,[n].concat(toConsumableArray(i)))}],[LCharacter,function(e,r){var n=r.quote;if(n){return e.toString()}return e.valueOf()}],[LString,function(e,r){var n=r.quote;e=e.toString();if(n){return JSON.stringify(e).replace(/\\n/g,"\n")}return e}],[RegExp,function(e){return"#"+e.toString()}]].forEach(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];instances.set(n,t)});function toString(e,r,n){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}if(str_mapping.has(e)){return str_mapping.get(e)}if(e){var t=e.constructor;if(instances.has(t)){for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}return instances.get(t)(e,{quote:r,skip_cycles:n,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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,n,t){if(n instanceof Pair){if(t.includes(n)){if(!a.includes(n)){a.push(n)}if(!e[__cycles__]){e[__cycles__]={}}e[__cycles__][r]=n;if(!i.includes(e)){i.push(e)}return true}}}var c=trampoline(function e(r,n){if(r instanceof Pair){delete r.ref;delete r[__cycles__];u(r);n.push(r);var t=o(r,"car",r.car,n);var i=o(r,"cdr",r.cdr,n);if(!t){c(r.car,n.slice())}if(!i){return new Thunk(function(){return e(r.cdr,n.slice())})}}});function n(e,r){if(e[__cycles__][r]instanceof Pair){var n=t.indexOf(e[__cycles__][r]);e[__cycles__][r]="#".concat(n,"#")}}c(e,[]);var t=r.filter(function(e){return a.includes(e)});t.forEach(function(e,r){e[__ref__]="#".concat(r,"=")});i.forEach(function(e){n(e,"car");n(e,"cdr")})}var pair_to_string=function(){var f=function e(r,n){var t=[];if(r[__ref__]){t.push(r[__ref__]+"(")}else if(!n){t.push("(")}return t};var _=function e(r,n){if(is_debug());if(!n||r[__ref__]){return[")"]}return[]};return trampoline(function e(r,n){var t=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{};var i=t.nested,a=i===void 0?false:i,u=t.result,o=u===void 0?[]:u,c=t.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,n,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,n,{nested:true,result:o,cont:s})}}else if(r.cdr!==nil){o.push(" . ");o.push(toString(r.cdr,n))}},s)})}();Pair.prototype.toString=function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.nested,t=n===void 0?false:n;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(!t){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(!t||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 n=toArray(r),t=n[0],i=n.slice(1);while(i.length>0){var a=i,u=slicedToArray(a,1),o=u[0];if(!e(t,o)){return false}var c=i;var s=toArray(c);t=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 n;if(e.__type__===r.__type__){if(e.__type__==="complex"){n=e.__im__.__type__===r.__im__.__type__&&e.__re__.__type__===r.__re__.__type__}else{n=true}if(n&&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,n,t){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(n){if(t){this.__doc__=n}else{this.__doc__=trim_lines(n)}}this.__name__=e;this.__fn__=r}Macro.defmacro=function(e,r,n,t){var i=new Macro(e,r,n,t);i.__defmacro__=true;return i};Macro.prototype.invoke=function(e,r,n){var t=r.env,i=r.dynamic_scope,a=r.error;var u={dynamic_scope:i,error:a,macro_expand:n};var o=this.__fn__.call(t,e,u,this.__name__);return o};Macro.prototype.toString=function(){return"#<macro:".concat(this.__name__,">")};var macro="define-macro";var recur_guard=-1e4;function macro_expand(a){return function(){var n=asyncToGenerator(regenerator.mark(function e(n,h){var t,m,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(n,t,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(!(n instanceof Pair&&n.car instanceof LSymbol)){r.next=26;break}if(!n[__data__]){r.next=3;break}return r.abrupt("return",n);case 3:a=i.get(n.car,{throwError:false});if(!(a instanceof Macro&&a.__defmacro__)){r.next=26;break}u=a instanceof Syntax?n:n.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(!(t!==-1&&t<=1||t<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(t!==-1){t=t-1}return r.abrupt("return",m(s,t,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(t!==-1&&t<=1||t<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(t!==-1){t=t-1}return r.abrupt("return",m(o,t,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=n.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return m(f,t,i);case 30:f=r.sent;case 31:_=n.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return m(_,t,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};m=function e(r,n,t){return i.apply(this,arguments)};t=h["env"]=this;if(!(n.cdr instanceof Pair&&LNumber.isNumber(n.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return m(n,n.cdr.car.valueOf(),t);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return m(n,1,t);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return m(n,-1,t);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return n.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,n){var t=r.error,i=r.env;var a={error:t,env:i,dynamic_scope:this.__env__,macro_expand:n};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};Syntax.className="syntax";function extract_patterns(e,r,D,w){var n=arguments.length>4&&arguments[4]!==undefined$1?arguments[4]:{};var L={"...":{symbols:{},lists:[]},symbols:{}};var x=n.expansion,F=n.define;function A(e){if(is_debug()){console.log(e)}}A(D);function E(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:[];var t=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.lastPair();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,n,t)){return false}}}if(e.car instanceof LSymbol){var _=e.car.__name__;if(L["..."].symbols[_]&&!n.includes(_)&&!t){throw new Error("syntax: named ellipsis can only appear onces")}A(">> 1");if(r===nil){A(">> 2");if(t){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 "+t);if(t){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 "+t);n.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 m=toConsumableArray(n);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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:t});if(t){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,n,t)){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,n,t)&&E(e.cdr.cdr.cdr,r.cdr,n,t)){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,n,t)&&E(e.cdr,r.cdr,n,t)){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 n=a(r.cdr);return new Pair(e,n)}else if(r instanceof LSymbol){var t=i.find(function(e){return e.gensym===r});if(t){return LSymbol(t.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 C(e){if(!c(e)){var r=type(e);throw new Error("syntax: internal error, need symbol got ".concat(r))}var n=e.valueOf();if(n===S){throw new Error("syntax: internal error, ellipis not transformed")}var t=_typeof_1(n);if(["string","symbol"].includes(t)){if(n in A.symbols){return A.symbols[n]}else if(t==="string"&&n.match(/\./)){var i=n.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(n)){return LSymbol(n)}return s(n)}function k(e){if(is_debug()){console.log(e)}}function s(e){if(!o[e]){var r=E.ref(e);var n=gensym(e);if(r){var t=E.get(e);E.set(n,t)}else{var i=E.get(e,{throwError:false});if(typeof i!=="undefined"){E.set(n,i)}}a.push({name:e,gensym:n});o[e]=n}return o[e]}function P(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=n.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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){t(a,new Pair(l,nil))}return s}if(c!==nil){t(a,c)}return o}else if(r[a]instanceof Array){t(a,r[a].slice(1));return r[a][0]}}return C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");t(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");t(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){t(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){t(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,n,t);var v=P(e.cdr,r,n,t);return new Pair(d,v)}return e}function N(r,n){var e=Object.values(r);var t=Object.getOwnPropertySymbols(r);if(t.length){e.push.apply(e,toConsumableArray(t.map(function(e){return r[e]})))}return e.length&&e.every(function(e){if(e===null){return!n}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;k("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){k(">> 1");var n=A["..."].symbols;var t=Object.values(n);if(t.length&&t.every(function(e){return e===null})){return B(i.cdr.cdr,{disabled:r})}var a=O(n);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))}k(">> 2");var c;if(a.length){k(">> 2 (a)");var s=_objectSpread({},n);c=nil;var l=function e(){if(!N(s)){return"break"}var t={};var r=function e(r,n){t[r]=n};var n=P(o,s,{nested:true},r);if(n!==undefined$1){if(u){if(c===nil){c=n}else{c=c.append(n)}}else{c=new Pair(n,c)}}s=t};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{k(">> 3");var p=P(i.car,n,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,n[h]);var d=n[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var t={};var r=function e(r,n){t[r]=n;if(is_debug()){console.log({NEWBIND:t[r].toString()})}};var n=P(i,m,{nested:false},r);k({value:n.toString()});if(typeof n!=="undefined"){v=new Pair(n,v)}m=t};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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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(t,i){var e=Object.getOwnPropertyNames(t);var r=Object.getOwnPropertySymbols(t);e.concat(r).forEach(function(e){var r=i(t[e]);var n=Object.getOwnPropertyDescriptor(t,e);if(!n||n.writable&&t[e]!==r){t[e]=r}});return t}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 n=r.bind(e);var t=Object.getOwnPropertyNames(r).filter(filter_fn_names);t.forEach(function(e){try{n[e]=r[e]}catch(e){}});hidden_prop(n,"__fn__",r);hidden_prop(n,"__context__",e);hidden_prop(n,"__bound__",true);if(is_native_function(r)){hidden_prop(n,"__native__",true)}if(is_plain_object(e)&&r[__lambda__]){hidden_prop(n,"__method__",true)}n.valueOf=function(){return r};return n}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,n){Object.defineProperty(e,Symbol["for"](r),{get:function e(){return n},set:function e(){},configurable:false,enumerable:false})}function setFnLength(r,n){try{Object.defineProperty(r,"length",{get:function e(){return n}});return r}catch(e){var t=new Array(n).fill(0).map(function(e,r){return"a"+r}).join(",");var i=new Function("f","return function(".concat(t,") {\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,n=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 t;if(r.cdr.car===nil){o=nil;t=nil}else{t=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(t,r.cdr.cdr))]],Pair(r.car,o)])}else if(n){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 n=o[_++];if(a){a=h==="let*"?s:c}if(!n){if(l&&l.length){var e=l.map(function(e){return e.value});var t=e.filter(is_promise);if(t.length){return Promise.all(e).then(function(e){for(var r=0,n=e.length;r<n;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,n=e.value;s.set(r,n)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(n.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:n.car,value:i});return r()}else{return unpromise(i,function(e){s.set(n.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;var i=this;if(n){n=this}var a=e;var u=[];while(a instanceof Pair){u.push(evaluate(a.car,{env:i,dynamic_scope:n,error:t}));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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}n.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,n)}function pipe(){var t=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.reduce(function(e,r){return[r.apply(t,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,n){typecheck(u,r,"function");for(var t=arguments.length,i=new Array(t>2?t-2:0),a=2;a<t;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof n==="number"){return LNumber(n)}return n}else{return o.call.apply(o,[c,e,r,n].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(t){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(t))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++){r[n-1]=arguments[n]}typecheck("curry",a,"function");var u=a.length;return function(){var t=r.slice();function i(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}t=t.concat(r);if(t.length>=u){return a.apply(this,t)}else{return i}}return i.apply(this,arguments)}}function limit(t,i){typecheck("limit",i,"function",2);return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return i.apply(void 0,toConsumableArray(r.slice(0,t)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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(t){return function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return t.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var n=e.valueOf();if(r<n){return-1}else if(r===n){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var n=[];if(e>0){n.push(this.__string__.substring(0,e))}n.push(r);if(e<this.__string__.length-1){n.push(this.__string__.substring(e+1))}this.__string__=n.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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 n=LNumber.getType(e);if(LNumber.types[n]){return LNumber.types[n](e,r)}var t=e instanceof Array&&LString.isString(e[0])&&LNumber.isNumber(e[1]);if(e instanceof LNumber){return LNumber(e.value)}if(!LNumber.isNumber(e)&&!t){throw new Error("You can't create LNumber from ".concat(type(e)))}if(e===null){e=0}var i;if(t){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(t){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(t){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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;return new LFloat(r,n)},complex:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isComplex(r)){r={im:0,re:r}}return new LComplex(r,n)},rational:function e(r){var n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:false;if(!LNumber.isRational(r)){r={num:r,denom:1}}return new LRational(r,n)}};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 n=r;r=e;e=n}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,n){return[r,n]};return{bigint:{bigint:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},integer:{integer:e,float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:function e(r,n){return[{num:r,denom:1},n]},complex:function e(r,n){return[{im:0,re:r},n]}},float:{bigint:function e(r,n){return[r,n&&LFloat(n.valueOf())]},integer:function e(r,n){return[r,n&&LFloat(n.valueOf())]},float:e,rational:function e(r,n){return[r,n&&LFloat(n.valueOf())]},complex:function e(r,n){return[{re:r,im:LFloat(0)},n]}},complex:{bigint:r("bigint"),integer:r("integer"),float:r("float"),rational:r("rational"),complex:function e(r,n){var t=LNumber.coerce(r.__re__,n.__re__),i=slicedToArray(t,2),a=i[0],u=i[1];var o=LNumber.coerce(r.__im__,n.__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,n){return[r,n&&{num:n,denom:1}]},integer:function e(r,n){return[r,n&&{num:n,denom:1}]},float:function e(r,n){return[LFloat(r.valueOf()),n]},rational:e,complex:function e(r,n){return[{im:coerce(r.__type__,n.__im__.__type__,0)[0],re:coerce(r.__type__,n.__re__.__type__,r)[0]},{im:coerce(r.__type__,n.__im__.__type__,n.__im__)[0],re:coerce(r.__type__,n.__re__.__type__,n.__re__)[0]}]}}};function r(n){return function(e,r){return[{im:coerce(n,e.__im__.__type__,0,e.__im__)[1],re:coerce(n,e.__re__.__type__,0,e.__re__)[1]},{im:coerce(n,e.__im__.__type__,0,0)[1],re:coerce(n,r.__type__,0,r)[1]}]}}}();function coerce(e,r,n,t){return matrix[e][r](n,t)}LNumber.coerce=function(e,r){var n=LNumber.getType(e);var t=LNumber.getType(r);if(!matrix[n]){throw new Error("LNumber::coerce unknown lhs type ".concat(n))}else if(!matrix[n][t]){throw new Error("LNumber::coerce unknown rhs type ".concat(t))}var i=matrix[n][t](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,n){return r*n},"+":function e(r,n){return r+n},"-":function e(r,n){if(typeof n==="undefined"){return-r}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<<n}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var n=this.coerce(r),t=slicedToArray(n,2),i=t[0],a=t[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,n){var t=typeof r==="bigint"?BigInt(1):1;return new Array(Number(n)).fill(0).reduce(function(e){return e*r},t)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(t.__type__==="bigint"){if(LNumber.isNative(t.__value__)){return a(t,i)}else if(LNumber.isBN(t.__value__)){return this.__value__.cmp(i.__value__)}}else if(t instanceof LFloat){return a(t,i)}};function LComplex(e){var r=arguments.length>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 n=e.im instanceof LNumber?e.im:LNumber(e.im);var t=e.re instanceof LNumber?e.re:LNumber(e.re);this.constant(n,t)}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 n=LFloat(this.__re__).toRational(e);return LComplex({im:r,re:n})}return this};LComplex.prototype.add=function(e){return this.complex_op("add",e,function(e,r,n,t){return{re:e.add(r),im:n.add(t)}})};LComplex.prototype.factor=function(){if(this.__im__ instanceof LFloat||this.__im__ instanceof LFloat){var e=this.__re__,r=this.__im__;var n,t;if(e instanceof LFloat){n=e.toRational().mul(e.toRational())}else{n=e.mul(e)}if(r instanceof LFloat){t=r.toRational().mul(r.toRational())}else{t=r.mul(r)}return n.add(t)}else{return this.__re__.mul(this.__re__).add(this.__im__.mul(this.__im__))}};LComplex.prototype.modulus=function(){return this.factor().sqrt()};LComplex.prototype.sqrt=function(){var e=this.modulus();var r,n;if(e.cmp(0)===0){r=n=e}else if(this.__re__.cmp(0)===1){r=LFloat(.5).mul(e.add(this.__re__)).sqrt();n=this.__im__.div(r).div(2)}else{n=LFloat(.5).mul(e.sub(this.__re__)).sqrt();if(this.__im__.cmp(0)===-1){n=n.sub()}r=this.__im__.div(n).div(2)}return LComplex({im:n,re:r})};LComplex.prototype.div=function(e){if(LNumber.isNumber(e)&&!LNumber.isComplex(e)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=t.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};LComplex.prototype.sub=function(e){return this.complex_op("sub",e,function(e,r,n,t){return{re:e.sub(r),im:n.sub(t)}})};LComplex.prototype.mul=function(e){return this.complex_op("mul",e,function(e,r,n,t){var i={re:e.mul(r).sub(n.mul(t)),im:e.mul(t).add(r.mul(n))};return i})};LComplex.prototype.complex_op=function(e,r,i){var a=this;var n=function e(r,n){var t=i(a.__re__,r,a.__im__,n);if("im"in t&&"re"in t){return LComplex(t,true)}return t};if(typeof r==="undefined"){return n()}if(LNumber.isNumber(r)&&!LNumber.isComplex(r)){if(!(r instanceof LNumber)){r=LNumber(r)}var t=r.asType(0);r={__im__:t,__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 n(u,o)};LComplex._op={"+":"add","-":"sub","*":"mul","/":"div"};LComplex.prototype._op=function(e,r){var n=LComplex._op[e];return this[n](r)};LComplex.prototype.cmp=function(e){var r=this.coerce(e),n=slicedToArray(r,2),t=n[0],i=n[1];var a=t.__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=t.__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 n=[Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY].includes(r);var t=toString(this.__im__);if(!n&&!Number.isNaN(r)){var i=this.__im__.cmp(0);if(i<0||i===0&&this.__im__._minus){e.push("-")}else{e.push("+")}t=t.replace(/^-/,"")}e.push(t);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 n=LNumber._ops[e];if(e==="/"&&this.__value__===0&&r===0){return NaN}return LFloat(n(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(t){return function(e){var r=function e(t,r,n){var i=function e(r,n){return n<t?r:e(n,r%n)};return i(Math.abs(r),Math.abs(n))},n=r(t?t:1/1e4,1,e);return LRational({num:Math.floor(e/n),denom:Math.floor(1/n)})}}function rationalize(e,r){var n=e.sub(r);var t=e.add(r);var i;if(n.cmp(t)>0){i=simplest_rational2(t,n)}else if(t.cmp(n)<=0){i=n}else if(n.cmp(0)>0){i=simplest_rational2(n,t)}else if(r.cmp(0)<0){i=LNumber(simplest_rational2(t.sub(),n.sub())).sub()}else{i=LNumber(0)}if(LNumber.isFloat(r)||LNumber.isFloat(e)){return LFloat(i)}return i}function simplest_rational2(e,r){var n=LNumber(e).floor();var t=LNumber(r).floor();if(e.cmp(n)<1){return n}else if(n.cmp(t)===0){var i=LNumber(1).div(r.sub(t));var a=LNumber(1).div(e.sub(n));return n.add(LNumber(1).div(simplest_rational2(i,a)))}else{return n.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 n,t;if(e instanceof LRational){n=LNumber(e.__num__);t=LNumber(e.__denom__)}else{n=LNumber(e.num);t=LNumber(e.denom)}if(!r&&t.cmp(0)!==0){var i=n.op("%",t).cmp(0)===0;if(i){return LNumber(n.div(t))}}this.constant(n,t)}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 n=this.__denom__.pow(e);var t=this.__num__.pow(e);return LRational({num:n,denom:t})}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,n;if(e.cmp(1)!==0){r=this.__num__.div(e);if(r instanceof LRational){r=LNumber(r.valueOf(true))}n=this.__denom__.div(e);if(n instanceof LRational){n=LNumber(n.valueOf(true))}}else{r=this.__num__;n=this.__denom__}var t=this.cmp(0)<0;if(t){if(r.abs().cmp(n.abs())===0){return r.toString()}}else if(r.cmp(n)===0){return r.toString()}return r.toString()+"/"+n.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 n=this.__denom__.mul(e.__denom__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=this.__denom__.mul(e.__num__);return LRational({num:r,denom:n})}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;return this.add(LRational({num:r,denom:n}))}if(!(e instanceof LNumber)){e=LNumber(e).sub()}else{e=e.sub()}var t=LNumber.coerce(this,e),i=slicedToArray(t,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 n=e.__denom__;var t=this.__num__;var i=e.__num__;var a,u;if(r!==n){u=n.mul(t).add(i.mul(r));a=r.mul(n)}else{u=t.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 n=LNumber._ops[e](this.__value__,r.__value__);if(e==="/"){var t=this.op("%",r).cmp(0)===0;if(t){return LNumber(n)}return LRational({num:this,denom:r})}return LBigInteger(n,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 t=this;if(typeof this!=="undefined"&&!(this instanceof InputPort)||typeof this==="undefined"){return new InputPort(e)}typecheck("InputPort",e,"function");this._read=e;this._with_parser=this._with_init_parser.bind(this,asyncToGenerator(regenerator.mark(function e(){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(t.char_ready()){r.next=5;break}r.next=3;return t._read();case 3:n=r.sent;t.__parser__=new Parser(n,{env:t});case 5:return r.abrupt("return",t.__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 n=LNumber.getType(r);typeErrorMessage("read-string",n,"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 n,t,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:n=r.sent;for(t=u.length,i=new Array(t),a=0;a<t;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[n].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");this._buffer=[];this.write=function(e){if(!LString.isString(e)){e=r(e)}else{e=e.valueOf()}n._buffer.push(e)}}OutputStringPort.prototype=Object.create(OutputPort.prototype);OutputStringPort.prototype.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;function OutputFilePort(e,r){var n=this;if(typeof this!=="undefined"&&!(this instanceof OutputFilePort)||typeof this==="undefined"){return new OutputFilePort(e,r)}typecheck("OutputFilePort",e,"string");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}n.fs("write")(n._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[e]};OutputFilePort.prototype.close=function(){var t=this;return new Promise(function(r,n){t.fs("close")(t._fd,function(e){if(e){n(e)}else{t._fd=null;OutputPort.prototype.close.call(t);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};function InputStringPort(e,r){var n=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(!n.__parser__){n.__parser__=new Parser(e,{env:r})}return n.__parser__});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"#<input-port <string>>"};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");this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};function Interpreter(e){var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.stderr,t=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:t,stdout:i,stderr:n},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(t)){o.set("stdin",t)}if(is_port(n)){o.set("stderr",n)}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 n=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(n===null){n=this.__env__}return exec(e,n,r?n: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,n){if(arguments.length===1){if(_typeof_1(arguments[0])==="object"){e=arguments[0];r=null}else if(typeof arguments[0]==="string"){e={};r=null;n=arguments[0]}}this.__docs__=new Map;this.__env__=e;this.__parent__=r;this.__name__=n||"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 n=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(!n){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 t=this.inherit("__frame__");t.set("parent.frame",doc("parent.frame",function(){var e=arguments.length>0&&arguments[0]!==undefined$1?arguments[0]:1;e=e.valueOf();var r=t.__parent__;if(!(r instanceof Environment)){return nil}if(e<=0){return r}var n=r.get("parent.frame");return n(e-1)},global_env.__env__["parent.frame"].__doc__));r.callee=e;t.set("arguments",r);return t};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:"+this.__name__+">"};Environment.prototype.clone=function(){var r=this;var n={};Object.keys(this.__env__).forEach(function(e){n[e]=r.__env__[e]});return new Environment(n,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 n=r.throwError,t=n===void 0?true:n;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(t){throw new Error("Unbound variable `"+i.toString()+"'")}};Environment.prototype.set=function(e,r){var n=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(n){this.doc(e,n)}return this};Environment.prototype.constant=function(r,e){var n=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 t=arguments[0];Object.keys(t).forEach(function(e){n.constant(r,t[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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(t[0])!=="symbol"){r=unbind(r)}var a;var u=t.length;while(t.length){var o=t.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(t.length){throw new Error("Try to get ".concat(t[0]," from undefined"))}return a}else{var s;if(t.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var n=interaction(e,"**internal-env**");return n.get(r)}function interaction(e,r){var n=e.get("**interaction-environment**");return n.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=asyncToGenerator(regenerator.mark(function e(n){var t,i,a,u,o,c,s,l;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:if(!LString.isString(n)){r.next=34;break}t=true;i=false;r.prev=3;u=asyncIterator(parse(n,this));case 5:r.next=7;return u.next();case 7:o=r.sent;t=o.done;r.next=11;return o.value;case 11:c=r.sent;if(t){r.next=18;break}s=c;return r.abrupt("return",s);case 15:t=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!t&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(n){typecheck("read",n,"input-port");l=n}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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 n=global_env.get("newline");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);n.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>t.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 n=t[o++];if(r==="a"){return c(n)}else{return c(n,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 n=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;if(n===null){n=internal(this,"stdout")}else{typecheck("display",n,"output-port")}var t=global_env.get("repr")(r);n.write.call(global_env,t)},"(display arg [port])\n\n Function send string to standard output or provied port."),error:doc(function e(){var r=internal(this,"stderr");var n=global_env.get("repr");for(var t=arguments.length,i=new Array(t),a=0;a<t;a++){i[a]=arguments[a]}var u=i.map(n).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var n=r.dynamic_scope,t=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(n){n=this}var u=evaluate(e.car,{env:a,error:t,dynamic_scope:n});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,n){return new Pair(r,n)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},n=r.dynamic_scope,t=r.error;if(n){n=this}var i=this;var u;var o=evaluate(e.cdr.car,{env:this,dynamic_scope:n,error:t});o=resolve_promises(o);function c(r,n,t){if(is_promise(r)){return r.then(function(e){return c(r,e,t)})}if(is_promise(n)){return n.then(function(e){return c(r,e,t)})}if(is_promise(t)){return t.then(function(e){return c(r,n,e)})}i.get("set-obj!").call(i,r,n,t);return t}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:n,error:t});var _=evaluate(l,{env:this,dynamic_scope:n,error:t});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 n=r.pop();var t=r.join(".");var i=a.get(t,{throwError:false});if(i){c(i,n,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 n=this.ref(r);if(n){delete n.__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,n){typecheck("load",r,"string");var t=this;if(t.__name__==="__frame__"){t=t.__parent__}if(!(n instanceof Environment)){if(t===global_env){n=t}else{n=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(/^#!.*/,""),n)}if(is_node()){return new Promise(function(n,t){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){t(e);global_env.set(i,a)}else{try{u(r).then(function(){n();global_env.set(i,a)})["catch"](t)}catch(e){t(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 n=asyncToGenerator(regenerator.mark(function e(n,t){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=t.dynamic_scope,a=t.error;u=this;if(i){i=u}o=u.inherit("do");c=n.car;s=n.cdr.car;l=n.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 n,t,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:n=c;t={};case 5:if(!(n!==nil)){r.next=15;break}i=n.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;t[i.car.valueOf()]=a;case 12:n=n.cdr;r.next=5;break;case 15:u=Object.getOwnPropertySymbols(t);Object.keys(t).concat(u).forEach(function(e){o.set(e,t[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 n.apply(this,arguments)}}()),"(do ((<var> <init> <next>)) (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(n,e){var t=e.dynamic_scope,i=e.error;if(t){t=this}var a=this;var r=function e(r){if(r===false){return evaluate(n.cdr.cdr.car,{env:a,dynamic_scope:t,error:i})}else{return evaluate(n.cdr.car,{env:a,dynamic_scope:t,error:i})}};if(n===nil){throw new Error("too few expressions for `if`")}var u=evaluate(n.car,{env:a,dynamic_scope:t,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 n=e.dynamic_scope,t=e.error;typecheck("let-env",r,"pair");var i=evaluate(r.car,{env:this,dynamic_scope:n,error:t});return unpromise(i,function(e){typecheck("let-env",e,"environment");return evaluate(Pair(LSymbol("begin"),r.cdr),{env:e,dynamic_scope:n,error:t})})},"(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 t=Object.assign({},r);var i=global_env.get("list->array")(e);if(t.dynamic_scope){t.dynamic_scope=this}t.env=this;var a;return function r(){if(i.length){var e=i.shift();var n=evaluate(e,t);return unpromise(n,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 n=r.dynamic_scope,t=r.error;var i={env:this,error:t};if(n){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(n,e){var t=this;if(n.car instanceof Pair&&n.car.car instanceof LSymbol){var r=new Pair(new LSymbol("define"),new Pair(n.car.car,new Pair(new Pair(new LSymbol("lambda"),new Pair(n.car.cdr,n.cdr)))));return r}else if(e.macro_expand){return}if(e.dynamic_scope){e.dynamic_scope=this}e.env=t;var i=n.cdr.car;var a;if(i instanceof Pair){i=evaluate(i,e);a=true}else if(i instanceof LSymbol){i=t.get(i)}typecheck("define",n.car,"symbol");return unpromise(i,function(e){if(t.__name__===Syntax.__merge_env__){t=t.__parent__}if(a&&(is_function(e)&&e[__lambda__]||e instanceof Syntax)){e.__name__=n.car.valueOf();if(e.__name__ instanceof LString){e.__name__=e.__name__.valueOf()}}var r;if(n.cdr.cdr instanceof Pair&&LString.isString(n.cdr.cdr.car)){r=n.cdr.cdr.car.valueOf()}t.set(n.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,n){var t=_typeof_1(e);if(is_null(e)||t!=="object"&&t!=="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(n)){e[r]=unbind(n);e[r][__prototype__]=true}else if(is_function(n)||is_native(n)||n===nil){e[r]=n}else{e[r]=n?n.valueOf():n}},"(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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return Values(n)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var n=e();if(n instanceof Values){return r.apply(void 0,toConsumableArray(n.valueOf()))}return r(n)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var t=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(t,r.message);if(r.code){var n=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(t,n)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){var e;if(_){if(!(this instanceof Environment)){e=h}else{e=this}}else{e=h}e=e.inherit("lambda");var r=f.car;var n=0;var t;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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=d;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){t=quote(Pair.fromArray(a.slice(n),false));e.__env__[r.__name__]=t;break}else{t=a[n];e.__env__[r.car.__name__]=t}}if(r.cdr===nil){break}n++;r=r.cdr}}if(_){_=e}var s=m?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;d.__code__=new Pair(new LSymbol("lambda"),f);d[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(d,m,true)}return doc(setFnLength(d,r),m,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var n=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var n=o.car.cdr;var t=e;while(true){if(n===nil){break}if(n instanceof LSymbol){r.__env__[n.__name__]=t;break}else if(n.car!==nil){if(t===nil){r.__env__[n.car.__name__]=nil}else{if(t.car instanceof Pair){t.car[__data__]=true}r.__env__[n.car.__name__]=t.car}}if(n.cdr===nil){break}if(t!==nil){t=t.cdr}n=n.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);n.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,n)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var n=e.car;r.push(n.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var n=new Syntax(function(e,r){var n=r.macro_expand;var t=g.inherit("syntax");if(y){y=t}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:t,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:t,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var m=i.merge(t,Syntax.__merge_env__);if(n){return{expr:f,scope:m}}var d=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:m}));return clear_gensyms(d,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);n.__code__=v;return n},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var n=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:a;if(e instanceof Pair){var t=e.car;var i=e.cdr;if(n(t)){t=r(t)}if(n(i)){i=r(i)}if(is_promise(t)||is_promise(i)){return Promise.all([t,i]).then(function(e){var r=slicedToArray(e,2),n=r[0],t=r[1];return new Pair(n,t)})}else{return new Pair(t,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 n(e){return!!e.filter(function(e){return e instanceof Pair&&LSymbol.is(e.car,"unquote")}).length}function f(e,t,i){return e.reduce(function(e,r){if(!(r instanceof Pair)){e.push(r);return e}if(LSymbol.is(r.car,"unquote-splicing")){var n;if(t+1<i){n=m(r.cdr,t+1,i)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(n instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(n.toArray())}e.push(m(r,t,i));return e},[])}function _(t,i,a){var u={};i++;Object.keys(t).forEach(function(e){var r=t[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var n;if(i<a){n=m(r.cdr.car,i,a)}else{n=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=n}else{u[e]=r}});if(Object.isFrozen(t)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,m(i.car.cdr,e,r)),nil)}var t=[];return function e(r){var n=evaluate(r.car,{env:s,dynamic_scope:o,error:c});t.push(n);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(t,function(n){if(n.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(n.length>1){var r="You can't splice multiple atoms inside list";throw new Error(r)}if(!(i.cdr instanceof Pair&&n[0]===nil)){return n[0]}}n=n.map(function(e){if(h.has(e)){return e.clone()}else{h.add(e);return e}});var t=m(i.cdr,0,1);if(t===nil&&n[0]===nil){return undefined$1}return unpromise(t,function(e){if(n[0]===nil){return e}if(n.length===1){return u(n[0],e)}var r=n.reduce(function(e,r){return u(e,r)});return u(r,e)})})}(i.car.cdr)}var h=new Set;function m(e,r,n){if(e instanceof Pair){if(LSymbol.is(e.car.car,"unquote-splicing")){return p(e,r+1,n)}if(LSymbol.is(e.car,"quasiquote")){var t=m(e.cdr,r,n+1);return new Pair(e.car,t)}if(LSymbol.is(e.car.car,"unquote")){if(r+2===n&&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,n)),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(n){if(n===nil){return Pair.fromArray(a)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){a.push(e);return r(n.cdr)})}(e.car.cdr)}else{return e.car.cdr}}}if(LSymbol.is(e.car,"quote")){return new Pair(e.car,m(e.cdr,r,n))}if(LSymbol.is(e.car,"unquote")){r++;if(r<n){return new Pair(new LSymbol("unquote"),m(e.cdr,r,n))}if(r>n){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(n){if(n===nil){return Pair.fromArray(u)}return unpromise(evaluate(n.car,{env:s,dynamic_scope:o,error:c}),function(e){u.push(e);return r(n.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 m(e,r,n)})}else if(is_plain_object(e)){return _(e,r,n)}else if(e instanceof Array){return f(e,r,n)}return e}function t(e){if(e instanceof Pair){delete e[__data__];if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}}if(is_plain_object(e.car)&&!n(Object.values(e.car))){return quote(e.car)}if(Array.isArray(e.car)&&!n(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=m(e.car,0,1);return unpromise(i,function(e){t(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 n=arguments.length,t=new Array(n),i=0;i<n;i++){t[i]=arguments[i]}t=t.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(t)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var n=global_env.get("list?");for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!n(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var n=global_env.get("list->array")(r).reverse();return global_env.get("array->list")(n)}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,n){typecheck("nth",r,"number");typecheck("nth",n,["array","pair"]);if(n instanceof Pair){var t=n;var i=0;while(i<r){if(!t.cdr||t.cdr===nil||t.haveCycles("cdr")){return nil}t=t.cdr;i++}return t.car}else if(n instanceof Array){return n[r]}else{throw new Error(typeErrorMessage("nth",type(n),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return n.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,n,t){typecheck("substring",r,"string");typecheck("substring",n,"number");typecheck("substring",t,["number","undefined"]);return r.substring(n.valueOf(),t&&t.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}n.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return n.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,n){typecheck("join",r,"string");typecheck("join",n,["pair","nil"]);return global_env.get("list->array")(n).join(r)},"(join separator list)\n\n Function return string by joining elements of the list"),split:doc(function e(r,n){typecheck("split",r,["regex","string"]);typecheck("split",n,"string");return global_env.get("array->list")(n.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,n,t){typecheck("replace",r,["regex","string"]);typecheck("replace",n,["string","function"]);typecheck("replace",t,"string");return t.replace(r,n)},"(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,n){typecheck("match",r,["regex","string"]);typecheck("match",n,"string");var t=n.match(r);return t?global_env.get("array->list")(t):nil},"(match pattern string)\n\n function return match object from JavaScript as list."),search:doc(function e(r,n){typecheck("search",r,["regex","string"]);typecheck("search",n,"string");return n.search(r)},"(search pattern string)\n\n Function return first found index of the pattern inside a string"),repr:doc(function e(r,n){return toString(r,n)},"(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 n;if(r.length){n=Pair.fromArray(r)}else{n=nil}if(e.__parent__ instanceof Environment){return global_env.get("env")(e.__parent__).append(n)}return n},"(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,n=new Array(r>1?r-1:0),t=1;t<r;t++){n[t-1]=arguments[t]}var i=construct(unbind(e),toConsumableArray(n.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var n=arguments.length>2&&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,n)},'(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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("list->array"),"(list->array list)\n\n Function convert LIPS list into JavaScript array."),apply:doc(function e(r){for(var n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=t.pop();typecheck("apply",a,["pair","nil"],t.length+2);t=t.concat(global_env.get("list->array").call(this,a));return r.apply(this,prepare_fn_args(r,t))},"(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 n=r===10&&!e.match(/e/i)||r===16;if(e.match(int_bare_re)&&n||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,t){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,n){o=t;unpromise(evaluate(new Pair(new LSymbol("begin"),u.cdr),c),function(){n(r)})}}var c={env:s,error:function e(r){var n=s.inherit("try");if(a){n.set(a.cdr.car.car,r);var t={env:n,error:f};if(l){t.dynamic_scope=s}unpromise(evaluate(new Pair(new LSymbol("begin"),a.cdr.cdr),t),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(n,t){typecheck("find",n,["regex","function"]);typecheck("find",t,["pair","nil"]);if(is_null(t)){return nil}var e=matcher("find",n);return unpromise(e(t.car),function(e){if(e&&e!==nil){return t.car}return r(n,t.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 n=arguments.length,t=new Array(n>1?n-1:0),i=1;i<n;i++){t[i-1]=arguments[i]}t.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(t));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(n){var t=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",n,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(t,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(n,o);s.set("parent.frame",c);return unpromise(n.call.apply(n,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[t,n].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(n,t){typecheck("some",n,"function");typecheck("some",t,["pair","nil"]);if(is_null(t)){return false}else{return unpromise(n(t.car),function(e){return e||r(n,t.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,n){for(var t=arguments.length,i=new Array(t>3?t-3:0),a=3;a<t;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return n}var u=e.call.apply(e,[this,r,n].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),n=0;n<r;n++){a[n]=arguments[n]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,n=slicedToArray(e,1),t=n[0];return r[t]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,n,e){var t=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",n,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(n.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[t,n,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,n){typecheck("filter",r,["regex","function"]);typecheck("filter",n,["pair","nil"]);var i=global_env.get("list->array")(n);var a=[];var u=matcher("filter",r);return function r(n){function e(e){if(e&&e!==nil){a.push(t)}return r(++n)}if(n===i.length){return Pair.fromArray(a)}var t=i[n];return unpromise(u(t),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,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}typecheck_args("lcm",n,"number");return n.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}typecheck_args("lcm",n,"number");var i=n.length,a=abs(n[0]);for(var u=1;u<i;u++){var o=abs(n[u]),c=a;while(a&&o){a>o?a%=o:o%=a}a=abs(c*n[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),n=0;n<e;n++){r[n]=arguments[n]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}typecheck_args(">",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),n=0;n<e;n++){r[n]=arguments[n]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}typecheck_args(">=",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 n=u.shift();var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=u.shift();if(typeof n==="undefined"){if(c!==false){return c}else{return false}}else{var t=evaluate(n,{env:o,dynamic_scope:i,error:a});return unpromise(t,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 n=e[r]?e[r]:r;global_env.set(n,doc(n,function(e){typecheck(n,e,"number");if(e instanceof LNumber){return e[r]()}},"(".concat(n," number)\n\n Function calculate ").concat(n," of a number.")))})})();function allPossibleCases(e){if(e.length===1){return e[0]}else{var r=[];var n=allPossibleCases(e.slice(1));for(var t=0;t<n.length;t++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+n[t])}}return r}}function combinations(e,r,n){var t=[];for(var i=r;i<=n;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}t=t.concat(allPossibleCases(a))}return t}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var n=r.slice().reverse();var t=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return n.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(t)))});function reversseFind(e,r){var n=e.split(path.sep).filter(Boolean);for(var t=n.length;t--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(n.slice(0,t+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var n;try{if(r.match(/^\s*\./)){n=nodeRequire(path.join(e,r))}else{var t=nodeModuleFind(e);if(t){n=nodeRequire(path.join(t,"node_modules",r))}else{n=nodeRequire(r)}}}catch(e){n=nodeRequire(r)}return patch_value(n,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;var i=e?" in expression `".concat(e,"`"):"";if(t!==null){i+=" (argument ".concat(t,")")}if(n instanceof Array){if(n.length===1){n=n[0]}else{var a=n[n.length-1];n=n.slice(0,-1).join(", ")+" or "+a}}return"Expecting ".concat(n,", got ").concat(r).concat(i)}function typecheck_args(n,e,t){e.forEach(function(e,r){typecheck(n,e,t,r+1)})}function typecheck(e,r,n){var t=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:null;e=e.valueOf();var i=type(r).toLowerCase();var a=false;if(n instanceof Pair){n=n.toArray()}if(n instanceof Array){n=n.map(function(e){return e.valueOf()})}if(n instanceof Array){n=n.map(function(e){return e.valueOf().toLowerCase()});if(n.includes(i)){a=true}}else{n=n.valueOf().toLowerCase()}if(!a&&i!==n){throw new Error(typeErrorMessage(e,i,n,t))}}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 n=0,t=Object.entries(r);n<t.length;n++){var i=slicedToArray(t[n],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];n(e);if(r.length){return a(e)}return e;function n(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){n(e.car)}if(!e.haveCycles("cdr")){n(e.cdr)}}else if(e instanceof Array){e.forEach(n)}}function t(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(n){var t;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!n.haveCycles("car")){r.next=5;break}r.t1=n.car;r.next=8;break;case 5:r.next=7;return a(n.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!n.haveCycles("cdr")){r.next=13;break}r.t3=n.cdr;r.next=16;break;case 13:r.next=15;return a(n.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;t=new r.t0(r.t2,r.t4);if(n[__data__]){t[__data__]=true}return r.abrupt("return",t);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return t(e)}return e}}function evaluate_args(e,r){var n=r.env,t=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:n,dynamic_scope:t,error:i});if(t){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(t)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,n){var t=e.invoke(r,n);return unpromise(resolve_promises(t),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,n){function t(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,n);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,n),t)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,n=new Array(r),t=0;t<r;t++){n[t]=arguments[t]}return unpromise(i.apply(this,n),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&arguments[2]!==undefined$1?arguments[2]:{},a=r.env,u=r.dynamic_scope,n=r.error,o=n===void 0?function(){}:n;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 n=(u||a).newFrame(i,r);var t=resolve_promises(i.apply(n,e));return unpromise(t,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]:{},n=e.env,t=e.dynamic_scope,i=e.error,a=i===void 0?function(){}:i;try{if(t===true){n=t=n||global_env}else if(n===true){n=t=global_env}else{n=n||global_env}var u={env:n,dynamic_scope:t,error:a};var o;if(is_null(r)){return r}if(r instanceof LSymbol){return n.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)+" "+n.get("repr")(o)+" is not a function while evaluating "+r.toString())}}if(c instanceof LSymbol){o=n.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 _=n.get(Symbol["for"]("__promise__"),{throwError:false});if(_===true&&is_promise(l)){return new QuotedPromise(l)}return l}catch(e){a&&a.call(n,e,r)}}function exec(e,r,n){return _exec.apply(this,arguments)}function _exec(){_exec=asyncToGenerator(regenerator.mark(function e(n,t,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){t=i=t||user_env}else if(t===true){t=i=user_env}else{t=t||user_env}a=[];u=true;o=false;r.prev=4;s=asyncIterator(parse(n));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:t,dynamic_scope:i,error:function e(r,n){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(n){if(!(r.__code__ instanceof Array)){r.__code__=[]}r.__code__.push(n.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 n;if(typeof e==="string"){n=tokenize(e)}else{n=e.map(function(e){return e&&e.token?e.token:e})}var t=Object.keys(r);var i=Object.values(r).concat(t);n=n.filter(function(e){return i.includes(e)});var a=new Stack;var u=_createForOfIteratorHelper(n),o;try{for(u.s();!(o=u.n()).done;){var c=o.value;if(t.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 n=window.URL||window.webkitURL;var t;try{t=new Blob([r],{type:"application/javascript"})}catch(e){var i=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder;t=new i;t.append(r);t=t.getBlob()}return new root.Worker(n.createObjectURL(t))}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 n=e.data;var r=n.id;if(n.type!=="RPC"||r===null){return}function t(e){self.postMessage({id:r,type:"RPC",result:e})}function i(e){self.postMessage({id:r,type:"RPC",error:e})}if(n.method==="eval"){if(!o){i("Worker RPC: LIPS not initilized, call init first");return}o.then(function(){var e=n.params[0];var r=n.params[1];u.exec(e,r).then(function(e){e=e.map(function(e){return e&&e.valueOf()});t(e)})["catch"](function(e){i(e)})})}else if(n.method==="init"){var a=n.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(){t(true)})}}})});this.rpc=function(){var t=0;return function e(r,n){var a=++t;return new Promise(function(t,i){u.addEventListener("message",function e(r){var n=r.data;if(n&&n.type==="RPC"&&n.id===a){if(n.error){i(n.error)}else{t(n.result)}u.removeEventListener("message",e)}});u.postMessage({type:"RPC",method:r,id:a,params:n})})}}();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(n){return new Promise(function(r){var e=n.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(n.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 n=r.getAttribute("type");if(u.includes(n)){var t=r.getAttribute("bootstrap");if(!o&&typeof t==="string"){bootstrap(t).then(function(){return c(r)}).then(e)}else{c(r).then(e)}}else if(n&&n.match(/lips|lisp/)){console.warn("Expecting "+u.join(" or ")+" found "+n)}return e()}}()})}if(!window.document){return Promise.resolve()}else if(currentScript){var r=currentScript;var n=r.getAttribute("bootstrap");if(typeof n==="string"){return bootstrap(n).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("Sun, 28 Feb 2021 14:26:21 +0000").valueOf();var r=e==="{{"+"DATE}}"?new Date:new Date(e);var n=function e(r){return r.toString().padStart(2,"0")};var t=r.getFullYear();var i=[t,n(r.getMonth()+1),n(r.getDate())].join("-");var a="\n __ __ __\n / / \\ \\ _ _ ___ ___ \\ \\\n| | \\ \\ | | | || . \\/ __> | |\n| | > \\ | |_ | || _/\\__ \\ | |\n| | / ^ \\ |___||_||_| <___/ | |\n \\_\\ /_/ \\_\\ /_/\n\nLIPS Interpreter DEV (".concat(i,") <https://lips.js.org>\nCopyright (c) 2018-").concat(t," 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:"Sun, 28 Feb 2021 14:26:21 +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,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var m="completed";var d={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===m){if(r==="throw"){throw t}return P()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,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(s===_){s=m;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?m:p;if(a.arg===d){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=m;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return d}var i=n.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}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function k(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return d}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e){this.complete(t.completion,t.afterLoc);S(t);return d}}},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:k(e),resultName:r,nextLoc:t};if(this.method==="next"){this.arg=c}return d}};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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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,m,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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",m(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",m(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return m(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return m(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};m=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return m(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return m(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return m(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 m=toConsumableArray(t);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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 C(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 k(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 P(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=t.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");n(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");n(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){n(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,t,n);var v=P(e.cdr,r,t,n);return new Pair(d,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;k("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){k(">> 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))}k(">> 2");var c;if(a.length){k(">> 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=P(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{k(">> 3");var p=P(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,t[h]);var d=t[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var n={};var r=function e(r,t){n[r]=t;if(is_debug()){console.log({NEWBIND:n[r].toString()})}};var t=P(i,m,{nested:false},r);k({value:t.toString()});if(typeof t!=="undefined"){v=new Pair(t,v)}m=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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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");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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}t.fs("write")(t._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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__});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"#<input-port <string>>"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");Object.defineProperty(this,"_vector",{enumerable:true,value:e});this._index=0}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#<input-port <bytevector>>"};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()===eof){return eof}return this._vector.slice(this._index,e)};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");Object.defineProperty(this,"_text",{value:true});this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=d;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=m?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;d.__code__=new Pair(new LSymbol("lambda"),f);d[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(d,m,true)}return doc(setFnLength(d,r),m,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var m=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:m}}var d=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:m}));return clear_gensyms(d,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=m(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(m(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=m(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,m(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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=m(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 m(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=m(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,m(e.cdr,r,t))}if(LSymbol.is(e.car,"unquote")){r++;if(r<t){return new Pair(new LSymbol("unquote"),m(e.cdr,r,t))}if(r>t){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 m(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=m(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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 28 Feb 2021 16:26:26 +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,") <https://lips.js.org>\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:"Sun, 28 Feb 2021 16:26:26 +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,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/dist/std.min.scm b/dist/std.min.scm index 0ce148d5..091e91c4 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -665,7 +665,17 @@ Function create new output port that can used to write string into and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr))(define (get-output-string port) "(get-output-string port) Function get full string from string port. If nothing was wrote -to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) +to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define (open-input-bytevector bytevector) "(open-input-bytevector bytevector) + +Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define (binary-port? port) (instanceof lips.InputByteVectorPort port))(define (textual-port? port) (and (port? port) (not (binary-port? port))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port"))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) +(peek-u8 port) + +Return next byte from input-binary port. If there are no more bytes +it return eof object." (lambda (port) (port.peek_u8)))(%define-binary-input-lambda read-u8 "(read-u8) +(read-u8 port) + +Read next byte from input-binary port. If there are no more bytes +it return eof object." (lambda (port) (port.read_u8)))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) Function delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename)))))))(define (call-with-port port proc) "(call-with-port port proc) diff --git a/dist/std.scm b/dist/std.scm index 0dde7f84..4c3c430c 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1216,14 +1216,16 @@ (let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) - (BrowserFS.configure &(:fs "IndexedDB" - :options &()) - (lambda (e) - (if (null? e) - (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) + (BrowserFS.configure + &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) + ;; --------------------------------------------------------------------------------------- (define (environment? obj) "(environment? obj) @@ -3378,6 +3380,59 @@ (type port)))) (port.getString))) +;; ----------------------------------------------------------------------------- +(define (open-input-bytevector bytevector) + "(open-input-bytevector bytevector) + + Create new input binary port with given bytevector" + (typecheck "open-input-bytevector" bytevector "uint8array") + (new lips.InputByteVectorPort bytevector)) + +;; ----------------------------------------------------------------------------- +;; temporary solution for tests +;; ----------------------------------------------------------------------------- +(define (binary-port? port) + (instanceof lips.InputByteVectorPort port)) + +(define (textual-port? port) + (and (port? port) (not (binary-port? port)))) + +;; ----------------------------------------------------------------------------- +(define-macro (%define-binary-input-lambda name docstring fn) + (let ((port (gensym)) + (name-str (symbol->string name))) + `(define (,name . rest) + ,docstring + (let ((,port (if (null? rest) + (current-input-port) + (car rest)))) + (typecheck ,name-str ,port "input-port") + (if (not (binary-port? ,port)) + (throw (new Error (string-append ,name-str " invalid port"))) + (,fn ,port)))))) + +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + peek-u8 + "(peek-u8) + (peek-u8 port) + + Return next byte from input-binary port. If there are no more bytes + it return eof object." + (lambda (port) + (port.peek_u8))) + +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + read-u8 + "(read-u8) + (read-u8 port) + + Read next byte from input-binary port. If there are no more bytes + it return eof object." + (lambda (port) + (port.read_u8))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 4183a295..06657e3b 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -590,6 +590,59 @@ (type port)))) (port.getString))) +;; ----------------------------------------------------------------------------- +(define (open-input-bytevector bytevector) + "(open-input-bytevector bytevector) + + Create new input binary port with given bytevector" + (typecheck "open-input-bytevector" bytevector "uint8array") + (new lips.InputByteVectorPort bytevector)) + +;; ----------------------------------------------------------------------------- +;; temporary solution for tests +;; ----------------------------------------------------------------------------- +(define (binary-port? port) + (instanceof lips.InputByteVectorPort port)) + +(define (textual-port? port) + (and (port? port) (not (binary-port? port)))) + +;; ----------------------------------------------------------------------------- +(define-macro (%define-binary-input-lambda name docstring fn) + (let ((port (gensym)) + (name-str (symbol->string name))) + `(define (,name . rest) + ,docstring + (let ((,port (if (null? rest) + (current-input-port) + (car rest)))) + (typecheck ,name-str ,port "input-port") + (if (not (binary-port? ,port)) + (throw (new Error (string-append ,name-str " invalid port"))) + (,fn ,port)))))) + +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + peek-u8 + "(peek-u8) + (peek-u8 port) + + Return next byte from input-binary port. If there are no more bytes + it return eof object." + (lambda (port) + (port.peek_u8))) + +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + read-u8 + "(read-u8) + (read-u8 port) + + Read next byte from input-binary port. If there are no more bytes + it return eof object." + (lambda (port) + (port.read_u8))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 94715ca0..cab6db40 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1216,14 +1216,16 @@ (let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) - (BrowserFS.configure &(:fs "IndexedDB" - :options &()) - (lambda (e) - (if (null? e) - (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) + (BrowserFS.configure + &(:fs "IndexedDB" + :options &()) + (lambda (e) + (if (null? e) + (resolve (BrowserFS.BFSRequire "fs")) + (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) + ;; --------------------------------------------------------------------------------------- (define (environment? obj) "(environment? obj) diff --git a/src/lips.js b/src/lips.js index 9c875651..2b150967 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5691,6 +5691,52 @@ return `#<input-port <string>>`; }; // ------------------------------------------------------------------------- + function InputByteVectorPort(bytevectors) { + if (typeof this !== 'undefined' && !(this instanceof InputByteVectorPort) || + typeof this === 'undefined') { + return new InputByteVectorPort(bytevectors); + } + typecheck('InputByteVectorPort', bytevectors, 'uint8array'); + Object.defineProperty(this, '_vector', { + enumerable: true, + value: bytevectors + }); + // TODO: Consider _index read/write typechecked property + this._index = 0; + } + InputByteVectorPort.prototype = Object.create(InputPort.prototype); + InputByteVectorPort.prototype.constructor = InputByteVectorPort; + InputByteVectorPort.prototype.toString = function() { + return `#<input-port <bytevector>>`; + }; + 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() { + const byte = this.peek_u8(); + this.skip(); + return byte; + }; + InputByteVectorPort.prototype.read_u8_vector = function(len) { + if (typeof len === 'undefined') { + len = this._vector.length; + } else if (len > this._index + this._vector.length) { + len = this._index + this._vector.length; + } + if (this.peek() === eof) { + return eof; + } + return this._vector.slice(this._index, len); + }; + // ------------------------------------------------------------------------- function InputFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || typeof this === 'undefined') { @@ -5698,6 +5744,9 @@ } InputStringPort.call(this, content); typecheck('InputFilePort', filename, 'string'); + Object.defineProperty(this, '_text', { + value: true + }); this.__filename__ = filename; } InputFilePort.prototype = Object.create(InputStringPort.prototype); @@ -5706,6 +5755,16 @@ return `#<input-port ${this.__filename__}>`; }; // ------------------------------------------------------------------------- + function InputFileBinaryPort(content, filename) { + if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || + typeof this === 'undefined') { + return new InputFilePort(content, filename); + } + InputStringPort.call(this, content); + typecheck('InputFilePort', filename, 'string'); + this.__filename__ = filename; + } + // ------------------------------------------------------------------------- var eof = new EOF(); function EOF() {} EOF.prototype.toString = function() { @@ -9470,6 +9529,7 @@ You can also use (help name) to display help for specic function or macro and OutputFilePort, InputStringPort, OutputStringPort, + InputByteVectorPort, Formatter, Parser, diff --git a/tests/ports.scm b/tests/ports.scm index 0af12797..0ccbb725 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -195,3 +195,22 @@ (let ((p (open-input-string "123456"))) (t.is (list (read-string 2 p) (read-string 2 p) (read-string 10 p)) '("12" "34" "56"))))) + +(test "port: open-input-bytevector" + (lambda (t) + (let ((p (open-input-bytevector #u8(100 200 300 400 500)))) + (t.is (binary-port? p) true) + (t.is (textual-port? p) false)))) + +(test "port: read from open-input-bytevector" + (lambda (t) + (let ((p (open-input-bytevector #u8(#x10 #x20 #xFF #xFF #xFF)))) + (t.is (peek-u8 p) #x10) + (t.is (read-u8 p) #x10) + (t.is (peek-u8 p) #x20) + (t.is (peek-u8 p) #x20) + (t.is (peek-u8 p) #x20) + (let ((result (vector))) + (while (not (eof-object? (peek-u8 p))) + (result.push (read-u8 p))) + (t.is result #(#x20 #xFF #xFF #xFF)))))) From 44a4ec53e343a2450efe19b00a45c0e8c6c403d9 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 1 Mar 2021 16:52:01 +0100 Subject: [PATCH 057/109] add Roadmap to Readme --- README.md | 20 +++++++++++++++++++- templates/README.md | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d8b5dc6..83b1b29c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&2580adf9a4633a1263a0915305033bb254045fcb)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&df23d954e272b794f73c708e69caee1e46d8aed2)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&73fdd331a2b532845b0f720c2d24e906)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) @@ -185,6 +185,24 @@ Executables also return a S-Expression according to SRFI-176 use `lips --version * [Git Repository](https://github.com/jcubic/lips) * [Official Website](https://lips.js.org/) +## Roadmap + +### 1.0 +- [x] Full support for R5RS +- [ ] Full support for R7RS +- [ ] Continuations. +- [ ] Tail Call Optimization (TCO). +- [ ] Fully tested Numerical Tower. +- [ ] R7RS libraries (`import`/`export`/`define-library`). +- [ ] All recursive function in JS don't consume stack. +- [ ] Finish `syntax-rules` (ignore limitations of current approach). + - [ ] Objects. + - [ ] Vectors. + +### 1.1 +- [ ] Proper expansion time for both macro system. +- [ ] Fully working and tested R7RS hygienic Macros (`syntax-rules`). + ## Acknowledgments * Font used in logo is [Telegrafico](https://www.dafont.com/telegrafico.font) by [ficod](https://www.deviantart.com/ficod). * Current parser is inspired by implementation in [BiwaScheme](https://www.biwascheme.org/) by Yutaka HARA (yhara). diff --git a/templates/README.md b/templates/README.md index b89a8a79..e9c2df4b 100644 --- a/templates/README.md +++ b/templates/README.md @@ -185,6 +185,24 @@ Executables also return a S-Expression according to SRFI-176 use `lips --version * [Git Repository](https://github.com/jcubic/lips) * [Official Website](https://lips.js.org/) +## Roadmap + +### 1.0 +- [x] Full support for R5RS +- [ ] Full support for R7RS +- [ ] Continuations. +- [ ] Tail Call Optimization (TCO). +- [ ] Fully tested Numerical Tower. +- [ ] R7RS libraries (`import`/`export`/`define-library`). +- [ ] All recursive function in JS don't consume stack. +- [ ] Finish `syntax-rules` (ignore limitations of current approach). + - [ ] Objects. + - [ ] Vectors. + +### 1.1 +- [ ] Proper expansion time for both macro system. +- [ ] Fully working and tested R7RS hygienic Macros (`syntax-rules`). + ## Acknowledgments * Font used in logo is [Telegrafico](https://www.dafont.com/telegrafico.font) by [ficod](https://www.deviantart.com/ficod). * Current parser is inspired by implementation in [BiwaScheme](https://www.biwascheme.org/) by Yutaka HARA (yhara). From 6a3de5309cde8646179f96abc4646960fed166cc Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 1 Mar 2021 17:14:06 +0100 Subject: [PATCH 058/109] add disabled/faling unit tests #43 --- tests/syntax.scm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/syntax.scm b/tests/syntax.scm index be357b41..973cfd66 100644 --- a/tests/syntax.scm +++ b/tests/syntax.scm @@ -937,3 +937,40 @@ (t.is (let*-values (((a b c) (values 1 2 3))) (+ a b c)) 6))) + +(test_ "syntax: nested _" + (lambda (t) + (define-syntax foo + (syntax-rules () + ((_) + (let () + (define-syntax %foo + (syntax-rules (foo bar) + ((_ (foo)) + "foo") + ((_) "bar") + ((_ x) + 'x))) + (list (%foo (foo)) + (%foo (10)) + (%foo bar) + (%foo)))))) + + (t.is (foo) '("foo" (10) bar "bar")))) + +(test_ "syntax: nesting, renaming and scope" + (lambda (t) + (let ((result 10)) + (define-syntax foo + (syntax-rules () + ((_) + (let () + (define-syntax %foo + (syntax-rules (foo bar) + ((__ (foo)) + (set! result '(foo))) + ((__ x) + (set! result 'x)))) + (%foo (foo)))))) + (foo) + (t.is result '(foo))))) From d005af547b59e83db4d531fc969a6e9d66f86c2a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 1 Mar 2021 19:02:50 +0100 Subject: [PATCH 059/109] improve binary ports #132 Add proper types for text and binary ports Add input file port support --- README.md | 4 +-- dist/lips.js | 92 +++++++++++++++++++++++++++++++++++++----------- dist/lips.min.js | 4 +-- dist/std.min.scm | 14 +++++--- dist/std.scm | 38 +++++++++++++------- lib/R5RS.scm | 4 --- lib/R7RS.scm | 34 +++++++++++++----- src/lips.js | 77 ++++++++++++++++++++++++++++------------ tests/ports.scm | 28 ++++++++++++++- 9 files changed, 219 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 83b1b29c..aed41a70 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&df23d954e272b794f73c708e69caee1e46d8aed2)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&73fdd331a2b532845b0f720c2d24e906)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&6a3de5309cde8646179f96abc4646960fed166cc)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&310826c951028f7809e8d816c41290a6)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index bd3f1fb9..8c09dfb3 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 16:26:26 +0000 + * build: Mon, 01 Mar 2021 17:56:17 +0000 */ (function () { 'use strict'; @@ -3350,6 +3350,15 @@ return fn(value); } // ---------------------------------------------------------------------- + + + function read_only(object, property, value) { + var hidden = arguments.length > 3 && arguments[3] !== undefined$1 ? arguments[3] : false; + Object.defineProperty(object, property, { + value: value, + enumerable: !hidden + }); + } // ---------------------------------------------------------------------- // :: Function similar to Array.from that work on async iterators // ---------------------------------------------------------------------- @@ -8698,6 +8707,7 @@ } typecheck('InputPort', read, 'function'); + read_only(this, '__type__', text_port); this._read = read; this._with_parser = this._with_init_parser.bind(this, /*#__PURE__*/asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() { var line; @@ -8834,6 +8844,7 @@ } typecheck('OutputPort', write, 'function'); + read_only(this, '__type__', text_port); this.write = write; } @@ -8869,6 +8880,7 @@ } typecheck('OutputStringPort', toString, 'function'); + read_only(this, '__type__', text_port); this._buffer = []; this.write = function (x) { @@ -8906,6 +8918,7 @@ typecheck('OutputFilePort', filename, 'string'); this._filename = filename; this._fd = fd.valueOf(); + read_only(this, '__type__', text_port); this.write = function (x) { if (!LString.isString(x)) { @@ -8971,6 +8984,7 @@ return _this11.__parser__; }); + read_only(this, '__type__', text_port); this._make_defaults(); } @@ -8993,12 +9007,32 @@ } typecheck('InputByteVectorPort', bytevectors, 'uint8array'); - Object.defineProperty(this, '_vector', { + read_only(this, '__vector__', bytevectors); + read_only(this, '__type__', binary_port); + var index = 0; + Object.defineProperty(this, '__index__', { enumerable: true, - value: bytevectors - }); // TODO: Consider _index read/write typechecked property + get: function get() { + return index; + }, + set: function set(value) { + typecheck('InputByteVectorPort::__index__', value, 'number'); - this._index = 0; + if (value instanceof LNumber) { + value = value.valueOf(); + } + + if (typeof value === 'bigint') { + value = Number(value); + } + + if (Math.floor(value) !== value) { + throw new Error('InputByteVectorPort::__index__ value is ' + 'not integer'); + } + + index = value; + } + }); } InputByteVectorPort.prototype = Object.create(InputPort.prototype); @@ -9009,16 +9043,16 @@ }; InputByteVectorPort.prototype.peek_u8 = function () { - if (this._index >= this._vector.length) { + if (this.__index__ >= this.__vector__.length) { return eof; } - return this._vector[this._index]; + return this.__vector__[this.__index__]; }; InputByteVectorPort.prototype.skip = function () { - if (this._index <= this._vector.length) { - ++this._index; + if (this.__index__ <= this.__vector__.length) { + ++this.__index__; } }; @@ -9031,16 +9065,16 @@ InputByteVectorPort.prototype.read_u8_vector = function (len) { if (typeof len === 'undefined') { - len = this._vector.length; - } else if (len > this._index + this._vector.length) { - len = this._index + this._vector.length; + len = this.__vector__.length; + } else if (len > this.__index__ + this.__vector__.length) { + len = this.__index__ + this.__vector__.length; } if (this.peek() === eof) { return eof; } - return this._vector.slice(this._index, len); + return this.__vector__.slice(this.__index__, len); }; // ------------------------------------------------------------------------- @@ -9051,10 +9085,7 @@ InputStringPort.call(this, content); typecheck('InputFilePort', filename, 'string'); - Object.defineProperty(this, '_text', { - value: true - }); - this.__filename__ = filename; + read_only(this, '__filename__', filename); } InputFilePort.prototype = Object.create(InputStringPort.prototype); @@ -9065,6 +9096,26 @@ }; // ------------------------------------------------------------------------- + function InputBinaryFilePort(content, filename) { + if (typeof this !== 'undefined' && !(this instanceof InputBinaryFilePort) || typeof this === 'undefined') { + return new InputBinaryFilePort(content, filename); + } + + InputByteVectorPort.call(this, content); + typecheck('InputBinaryFilePort', filename, 'string'); + read_only(this, '__filename__', filename); + } + + InputBinaryFilePort.prototype = Object.create(InputByteVectorPort.prototype); + InputBinaryFilePort.prototype.constructor = InputBinaryFilePort; + + InputBinaryFilePort.prototype.toString = function () { + return "#<input-binary-port ".concat(this.__filename__, ">"); + }; // ------------------------------------------------------------------------- + + + var binary_port = Symbol["for"]('binary'); + var text_port = Symbol["for"]('text'); var eof = new EOF(); function EOF() {} @@ -13379,10 +13430,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 28 Feb 2021 16:26:26 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Mon, 01 Mar 2021 17:56:17 +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('Sun, 28 Feb 2021 16:26:26 +0000').valueOf(); + var date = LString('Mon, 01 Mar 2021 17:56:17 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13422,7 +13473,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 28 Feb 2021 16:26:26 +0000', + date: 'Mon, 01 Mar 2021 17:56:17 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), @@ -13449,6 +13500,7 @@ InputStringPort: InputStringPort, OutputStringPort: OutputStringPort, InputByteVectorPort: InputByteVectorPort, + InputBinaryFilePort: InputBinaryFilePort, Formatter: Formatter, Parser: Parser, Lexer: Lexer, diff --git a/dist/lips.min.js b/dist/lips.min.js index 4e3fcc49..f4937e48 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 28 Feb 2021 16:26:26 +0000 + * build: Mon, 01 Mar 2021 17:56:17 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var m="completed";var d={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(k([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===m){if(r==="throw"){throw t}return P()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,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(s===_){s=m;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?m:p;if(a.arg===d){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=m;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return d}var i=n.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}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function k(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:P}}u.values=k;function P(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return d}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return d},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e){this.complete(t.completion,t.afterLoc);S(t);return d}}},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:k(e),resultName:r,nextLoc:t};if(this.method==="next"){this.arg=c}return d}};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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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,m,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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",m(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",m(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return m(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return m(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};m=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return m(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return m(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return m(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 m=toConsumableArray(t);if(r===nil){A(">> 9");L["..."].lists.push(nil);return true}A(">> 10");var d=r;while(d instanceof Pair){if(!E(e.car,d.car,m,true)){return false}d=d.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 C(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 k(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 P(e,r,t){var n=arguments.length>3&&arguments[3]!==undefined$1?arguments[3]:function(){};var i=t.nested;k(" ==> "+e.toString(true));k(r);if(e instanceof LSymbol){var a=e.valueOf();k("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){k("[t 2");var f=e.car.valueOf();var _=r[f];k({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){k({b:r[f].toString()});if(_ instanceof Pair){k("[t 2 Pair "+i);k({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){k("|| next 1");n(f,h)}k({car:p.toString()});return p}else{if(p.cdr!==nil){k("|| next 2");n(f,new Pair(p.cdr,h))}k({car:p.car.toString()});return p.car}}else if(_ instanceof Array){k("[t 2 Array "+i);if(i){n(f,_.slice(1));return Pair.fromArray(_)}else{var m=_.slice(1);if(m.length){n(f,m)}return _[0]}}else{return _}}}k("[t 3 recur "+e.toString());var d=P(e.car,r,t,n);var v=P(e.cdr,r,t,n);return new Pair(d,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;k("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){k(">> 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))}k(">> 2");var c;if(a.length){k(">> 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=P(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{k(">> 3");var p=P(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){k(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){k(">> 4 (a)")}else{k(">> 4 (b)")}var h=i.car.__name__;var m=defineProperty({},h,t[h]);var d=t[h]===null;var v=nil;var y=function e(){if(!N(m,true)){k({bind:m});return"break"}var n={};var r=function e(r,t){n[r]=t;if(is_debug()){console.log({NEWBIND:n[r].toString()})}};var t=P(i,m,{nested:false},r);k({value:t.toString()});if(typeof t!=="undefined"){v=new Pair(t,v)}m=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(d){return g}k("<<<< 1");v.append(g)}}k("<<<< 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})}k({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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");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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};function OutputPort(e){if(typeof this!=="undefined"&&!(this instanceof OutputPort)||typeof this==="undefined"){return new OutputPort(e)}typecheck("OutputPort",e,"function");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"#<output-port>"};function OutputStringPort(r){var t=this;if(typeof this!=="undefined"&&!(this instanceof OutputStringPort)||typeof this==="undefined"){return new OutputStringPort(r)}typecheck("OutputStringPort",r,"function");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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();this.write=function(e){if(!LString.isString(e)){e=toString(e)}else{e=e.valueOf()}t.fs("write")(t._fd,e,function(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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__});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"#<input-port <string>>"};function InputByteVectorPort(e){if(typeof this!=="undefined"&&!(this instanceof InputByteVectorPort)||typeof this==="undefined"){return new InputByteVectorPort(e)}typecheck("InputByteVectorPort",e,"uint8array");Object.defineProperty(this,"_vector",{enumerable:true,value:e});this._index=0}InputByteVectorPort.prototype=Object.create(InputPort.prototype);InputByteVectorPort.prototype.constructor=InputByteVectorPort;InputByteVectorPort.prototype.toString=function(){return"#<input-port <bytevector>>"};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()===eof){return eof}return this._vector.slice(this._index,e)};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");Object.defineProperty(this,"_text",{value:true});this.__filename__=r}InputFilePort.prototype=Object.create(InputStringPort.prototype);InputFilePort.prototype.constructor=InputFilePort;InputFilePort.prototype.toString=function(){return"#<input-port ".concat(this.__filename__,">")};var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:{},_=e.dynamic_scope,p=e.error;var h=this;var m;if(f.cdr instanceof Pair&&LString.isString(f.cdr.car)&&f.cdr.cdr!==nil){m=f.cdr.car.valueOf()}function d(){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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=d;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=m?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;d.__code__=new Pair(new LSymbol("lambda"),f);d[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(d,m,true)}return doc(setFnLength(d,r),m,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var m=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:m}}var d=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:m}));return clear_gensyms(d,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=m(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(m(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=m(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,m(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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=m(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 m(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=m(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,m(e.cdr,r,t))}if(LSymbol.is(e.car,"unquote")){r++;if(r<t){return new Pair(new LSymbol("unquote"),m(e.cdr,r,t))}if(r>t){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 m(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=m(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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 28 Feb 2021 16:26:26 +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,") <https://lips.js.org>\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:"Sun, 28 Feb 2021 16:26:26 +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,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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);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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port <string>>"};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"#<input-port <bytevector>>"};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()===eof){return eof}return this.__vector__.slice(this.__index__,e)};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"#<input-port ".concat(this.__filename__,">")};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"#<input-binary-port ".concat(this.__filename__,">")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Mon, 01 Mar 2021 17:56:17 +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,") <https://lips.js.org>\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:"Mon, 01 Mar 2021 17:56:17 +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,InputBinaryFilePort:InputBinaryFilePort,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/dist/std.min.scm b/dist/std.min.scm index 091e91c4..f0770014 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -531,10 +531,7 @@ for interactive ports that return false if it would wait for user input. It return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready)))(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename) Function return new Input Port with given filename. In Browser user need to -provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) "(readFile filename) - -Helper function that return Promise. NodeJS function sometimes give warnings -when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename)))))))(define (close-input-port port) "(close-input-port port) +provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename)))))))(define (close-input-port port) "(close-input-port port) Procedure close port that was opened with open-input-file. After that it no longer accept reading from that port." (typecheck "close-input-port" port "input-port") (port.close))(define (close-output-port port) "(close-output-port port) @@ -667,7 +664,14 @@ and after finish get the whole string using `get-output-string`." (new lips.Outp Function get full string from string port. If nothing was wrote to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define (open-input-bytevector bytevector) "(open-input-bytevector bytevector) -Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define (binary-port? port) (instanceof lips.InputByteVectorPort port))(define (textual-port? port) (and (port? port) (not (binary-port? port))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port"))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) +Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define open-binary-input-file (let ((readFile #f)) (lambda (filename) "(open-binary-input-file filename) + +Function return new Input Binary Port with given filename. In Browser +user need to provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-binary-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) (Uint8Array.from (_readFile filename)))))) (new lips.InputBinaryFilePort (readFile filename) filename)))))))(define (binary-port? port) "(binary-port? port) + +Function test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary"))))(define (textual-port? port) "(textual-port? port) + +Function test if argument is string port." (and (port? port) (eq? port.__type__ (Symbol.for "text"))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port"))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) (peek-u8 port) Return next byte from input-binary port. If there are no more bytes diff --git a/dist/std.scm b/dist/std.scm index 4c3c430c..565ebe37 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2501,10 +2501,6 @@ (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) - "(readFile filename) - - Helper function that return Promise. NodeJS function sometimes give warnings - when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename))))))) @@ -2827,11 +2823,6 @@ (and (symbol? a) (symbol? b) (equal? a b))) args)) -;;(define (read-line . rest) -;; (let ((port (if (null? rest) (current-input-port) (car rest)))) -;; (while (let ((char (peek-char port))) -;; (and (not (string? - ;; ----------------------------------------------------------------------------- ;; function for Gauche code ;; ----------------------------------------------------------------------------- @@ -3389,13 +3380,36 @@ (new lips.InputByteVectorPort bytevector)) ;; ----------------------------------------------------------------------------- -;; temporary solution for tests +(define open-binary-input-file + (let ((readFile #f)) + (lambda(filename) + "(open-binary-input-file filename) + + Function return new Input Binary Port with given filename. In Browser + user need to provide global fs variable that is instance of FS interface." + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-binary-input-file: fs not defined")) + (begin + (if (not (procedure? readFile)) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (filename) + (Uint8Array.from (_readFile filename)))))) + (new lips.InputBinaryFilePort (readFile filename) filename))))))) + ;; ----------------------------------------------------------------------------- (define (binary-port? port) - (instanceof lips.InputByteVectorPort port)) + "(binary-port? port) + Function test if argument is binary port." + (and (port? port) (eq? port.__type__ (Symbol.for "binary")))) + +;; ----------------------------------------------------------------------------- (define (textual-port? port) - (and (port? port) (not (binary-port? port)))) + "(textual-port? port) + + Function test if argument is string port." + (and (port? port) (eq? port.__type__ (Symbol.for "text")))) ;; ----------------------------------------------------------------------------- (define-macro (%define-binary-input-lambda name docstring fn) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 49e79635..99ae3661 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -1265,10 +1265,6 @@ (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) - "(readFile filename) - - Helper function that return Promise. NodeJS function sometimes give warnings - when using fs.promises on Windows." (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename))))))) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 06657e3b..077b5c52 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -37,11 +37,6 @@ (and (symbol? a) (symbol? b) (equal? a b))) args)) -;;(define (read-line . rest) -;; (let ((port (if (null? rest) (current-input-port) (car rest)))) -;; (while (let ((char (peek-char port))) -;; (and (not (string? - ;; ----------------------------------------------------------------------------- ;; function for Gauche code ;; ----------------------------------------------------------------------------- @@ -599,13 +594,36 @@ (new lips.InputByteVectorPort bytevector)) ;; ----------------------------------------------------------------------------- -;; temporary solution for tests +(define open-binary-input-file + (let ((readFile #f)) + (lambda(filename) + "(open-binary-input-file filename) + + Function return new Input Binary Port with given filename. In Browser + user need to provide global fs variable that is instance of FS interface." + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-binary-input-file: fs not defined")) + (begin + (if (not (procedure? readFile)) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (filename) + (Uint8Array.from (_readFile filename)))))) + (new lips.InputBinaryFilePort (readFile filename) filename))))))) + ;; ----------------------------------------------------------------------------- (define (binary-port? port) - (instanceof lips.InputByteVectorPort port)) + "(binary-port? port) + + Function test if argument is binary port." + (and (port? port) (eq? port.__type__ (Symbol.for "binary")))) +;; ----------------------------------------------------------------------------- (define (textual-port? port) - (and (port? port) (not (binary-port? port)))) + "(textual-port? port) + + Function test if argument is string port." + (and (port? port) (eq? port.__type__ (Symbol.for "text")))) ;; ----------------------------------------------------------------------------- (define-macro (%define-binary-input-lambda name docstring fn) diff --git a/src/lips.js b/src/lips.js index 2b150967..a3537a6a 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1526,6 +1526,12 @@ } } return fn(value); + }// ---------------------------------------------------------------------- + function read_only(object, property, value, hidden = false) { + Object.defineProperty(object, property, { + value, + enumerable: !hidden + }); } // ---------------------------------------------------------------------- // :: Function similar to Array.from that work on async iterators @@ -5510,6 +5516,7 @@ return new InputPort(read); } typecheck('InputPort', read, 'function'); + read_only(this, '__type__', text_port); this._read = read; this._with_parser = this._with_init_parser.bind(this, async () => { if (!this.char_ready()) { @@ -5578,6 +5585,7 @@ return new OutputPort(write); } typecheck('OutputPort', write, 'function'); + read_only(this, '__type__', text_port); this.write = write; } OutputPort.prototype.is_open = function() { @@ -5604,6 +5612,7 @@ return new OutputStringPort(toString); } typecheck('OutputStringPort', toString, 'function'); + read_only(this, '__type__', text_port); this._buffer = []; this.write = (x) => { if (!LString.isString(x)) { @@ -5631,6 +5640,7 @@ typecheck('OutputFilePort', filename, 'string'); this._filename = filename; this._fd = fd.valueOf(); + read_only(this, '__type__', text_port); this.write = (x) => { if (!LString.isString(x)) { x = toString(x); @@ -5680,6 +5690,7 @@ } return this.__parser__; }); + read_only(this, '__type__', text_port); this._make_defaults(); } InputStringPort.prototype.char_ready = function() { @@ -5697,12 +5708,29 @@ return new InputByteVectorPort(bytevectors); } typecheck('InputByteVectorPort', bytevectors, 'uint8array'); - Object.defineProperty(this, '_vector', { + read_only(this, '__vector__', bytevectors); + read_only(this, '__type__', binary_port); + var index = 0; + Object.defineProperty(this, '__index__', { enumerable: true, - value: bytevectors + get: function() { + return index; + }, + set: function(value) { + typecheck('InputByteVectorPort::__index__', value, 'number'); + if (value instanceof LNumber) { + value = value.valueOf(); + } + if (typeof value === 'bigint') { + value = Number(value); + } + if (Math.floor(value) !== value) { + throw new Error('InputByteVectorPort::__index__ value is ' + + 'not integer'); + } + index = value; + } }); - // TODO: Consider _index read/write typechecked property - this._index = 0; } InputByteVectorPort.prototype = Object.create(InputPort.prototype); InputByteVectorPort.prototype.constructor = InputByteVectorPort; @@ -5710,14 +5738,14 @@ return `#<input-port <bytevector>>`; }; InputByteVectorPort.prototype.peek_u8 = function() { - if (this._index >= this._vector.length) { + if (this.__index__ >= this.__vector__.length) { return eof; } - return this._vector[this._index]; + return this.__vector__[this.__index__]; }; InputByteVectorPort.prototype.skip = function() { - if (this._index <= this._vector.length) { - ++this._index; + if (this.__index__ <= this.__vector__.length) { + ++this.__index__; } }; InputByteVectorPort.prototype.read_u8 = function() { @@ -5727,14 +5755,14 @@ }; InputByteVectorPort.prototype.read_u8_vector = function(len) { if (typeof len === 'undefined') { - len = this._vector.length; - } else if (len > this._index + this._vector.length) { - len = this._index + this._vector.length; + len = this.__vector__.length; + } else if (len > this.__index__ + this.__vector__.length) { + len = this.__index__ + this.__vector__.length; } if (this.peek() === eof) { return eof; } - return this._vector.slice(this._index, len); + return this.__vector__.slice(this.__index__, len); }; // ------------------------------------------------------------------------- function InputFilePort(content, filename) { @@ -5744,10 +5772,7 @@ } InputStringPort.call(this, content); typecheck('InputFilePort', filename, 'string'); - Object.defineProperty(this, '_text', { - value: true - }); - this.__filename__ = filename; + read_only(this, '__filename__', filename); } InputFilePort.prototype = Object.create(InputStringPort.prototype); InputFilePort.prototype.constructor = InputFilePort; @@ -5755,16 +5780,23 @@ return `#<input-port ${this.__filename__}>`; }; // ------------------------------------------------------------------------- - function InputFileBinaryPort(content, filename) { - if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || + function InputBinaryFilePort(content, filename) { + if (typeof this !== 'undefined' && !(this instanceof InputBinaryFilePort) || typeof this === 'undefined') { - return new InputFilePort(content, filename); + return new InputBinaryFilePort(content, filename); } - InputStringPort.call(this, content); - typecheck('InputFilePort', filename, 'string'); - this.__filename__ = filename; + InputByteVectorPort.call(this, content); + typecheck('InputBinaryFilePort', filename, 'string'); + read_only(this, '__filename__', filename); } + InputBinaryFilePort.prototype = Object.create(InputByteVectorPort.prototype); + InputBinaryFilePort.prototype.constructor = InputBinaryFilePort; + InputBinaryFilePort.prototype.toString = function() { + return `#<input-binary-port ${this.__filename__}>`; + }; // ------------------------------------------------------------------------- + const binary_port = Symbol.for('binary'); + const text_port = Symbol.for('text'); var eof = new EOF(); function EOF() {} EOF.prototype.toString = function() { @@ -9530,6 +9562,7 @@ You can also use (help name) to display help for specic function or macro and InputStringPort, OutputStringPort, InputByteVectorPort, + InputBinaryFilePort, Formatter, Parser, diff --git a/tests/ports.scm b/tests/ports.scm index 0ccbb725..80e05d68 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -198,7 +198,7 @@ (test "port: open-input-bytevector" (lambda (t) - (let ((p (open-input-bytevector #u8(100 200 300 400 500)))) + (let ((p (open-input-bytevector #u8(#x10 #x20 #xFF #xFF #xFF)))) (t.is (binary-port? p) true) (t.is (textual-port? p) false)))) @@ -214,3 +214,29 @@ (while (not (eof-object? (peek-u8 p))) (result.push (read-u8 p))) (t.is result #(#x20 #xFF #xFF #xFF)))))) + +(test "port: textual-port?" + (lambda (t) + (let* ((closable (list (open-input-file "./tests/ports.scm") + (open-input-string "xxx") + (open-output-string) + (open-output-file "./tests/__x6__.scm"))) + (ports (append (list (current-input-port) + (current-output-port)) + closable))) + (for-each (lambda (p) + (t.is (textual-port? p) true)) + ports) + (for-each close-port closable) + (delete-file "./tests/__x6__.scm")))) + +(test "port: read binary" + (lambda (t) + (let* ((fname "./tests/stubs/test.txt") + (p (open-binary-input-file fname)) + (result (vector)) + (fs (require "fs"))) + (while (not (eof-object? (peek-u8 p))) + (result.push (string (integer->char (read-u8 p))))) + (t.is (result.join "") (--> (fs.promises.readFile fname) + (toString)))))) From ef950e218d00a98bc28f168e5fd6c294d60fc661 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Mon, 1 Mar 2021 19:32:23 +0100 Subject: [PATCH 060/109] read-bytevector function #132 --- README.md | 4 ++-- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- dist/std.min.scm | 7 ++++++- dist/std.scm | 16 ++++++++++++++++ lib/R7RS.scm | 16 ++++++++++++++++ src/lips.js | 2 +- tests/ports.scm | 28 +++++++++++++++++----------- 8 files changed, 65 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index aed41a70..0c503f68 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&6a3de5309cde8646179f96abc4646960fed166cc)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&310826c951028f7809e8d816c41290a6)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&d005af547b59e83db4d531fc969a6e9d66f86c2a)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ed932744444165faed2c85da45bc843d)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 8c09dfb3..e728b43e 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 01 Mar 2021 17:56:17 +0000 + * build: Mon, 01 Mar 2021 18:29:03 +0000 */ (function () { 'use strict'; @@ -9070,7 +9070,7 @@ len = this.__index__ + this.__vector__.length; } - if (this.peek() === eof) { + if (this.peek_u8() === eof) { return eof; } @@ -13430,10 +13430,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 01 Mar 2021 17:56:17 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Mon, 01 Mar 2021 18:29:03 +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('Mon, 01 Mar 2021 17:56:17 +0000').valueOf(); + var date = LString('Mon, 01 Mar 2021 18:29:03 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13473,7 +13473,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Mon, 01 Mar 2021 17:56:17 +0000', + date: 'Mon, 01 Mar 2021 18:29:03 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index f4937e48..8d8e2715 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 01 Mar 2021 17:56:17 +0000 + * build: Mon, 01 Mar 2021 18:29:03 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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);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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port <string>>"};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"#<input-port <bytevector>>"};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()===eof){return eof}return this.__vector__.slice(this.__index__,e)};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"#<input-port ".concat(this.__filename__,">")};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"#<input-binary-port ".concat(this.__filename__,">")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Mon, 01 Mar 2021 17:56:17 +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,") <https://lips.js.org>\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:"Mon, 01 Mar 2021 17:56:17 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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);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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port <string>>"};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"#<input-port <bytevector>>"};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 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"#<input-port ".concat(this.__filename__,">")};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"#<input-binary-port ".concat(this.__filename__,">")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Mon, 01 Mar 2021 18:29:03 +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,") <https://lips.js.org>\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:"Mon, 01 Mar 2021 18:29:03 +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,InputBinaryFilePort:InputBinaryFilePort,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/dist/std.min.scm b/dist/std.min.scm index f0770014..ec0f8ea0 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -679,7 +679,12 @@ it return eof object." (lambda (port) (port.peek_u8)))(%define-binary-input-lamb (read-u8 port) Read next byte from input-binary port. If there are no more bytes -it return eof object." (lambda (port) (port.read_u8)))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) +it return eof object." (lambda (port) (port.read_u8)))(define (read-bytevector k . rest) "(read-bytevector k) +(read-bytevector k port) + +Read next n bytes from input-binary port. If there are no more bytes +it returns eof object. If there are less then n bytes in port it +return the only bytes that are available" (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-bytevector" port "input-port") (if (not (binary-port? port)) (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k))))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) Function delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename)))))))(define (call-with-port port proc) "(call-with-port port proc) diff --git a/dist/std.scm b/dist/std.scm index 565ebe37..ee076b78 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3447,6 +3447,22 @@ (lambda (port) (port.read_u8))) +;; ----------------------------------------------------------------------------- +(define (read-bytevector k . rest) + "(read-bytevector k) + (read-bytevector k port) + + Read next n bytes from input-binary port. If there are no more bytes + it returns eof object. If there are less then n bytes in port it + return the only bytes that are available" + (let ((port (if (null? rest) + (current-input-port) + (car rest)))) + (typecheck "read-bytevector" port "input-port") + (if (not (binary-port? port)) + (throw (new Error "read-bytevector: invalid port")) + (port.read_u8_vector k)))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 077b5c52..561ecb73 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -661,6 +661,22 @@ (lambda (port) (port.read_u8))) +;; ----------------------------------------------------------------------------- +(define (read-bytevector k . rest) + "(read-bytevector k) + (read-bytevector k port) + + Read next n bytes from input-binary port. If there are no more bytes + it returns eof object. If there are less then n bytes in port it + return the only bytes that are available" + (let ((port (if (null? rest) + (current-input-port) + (car rest)))) + (typecheck "read-bytevector" port "input-port") + (if (not (binary-port? port)) + (throw (new Error "read-bytevector: invalid port")) + (port.read_u8_vector k)))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/src/lips.js b/src/lips.js index a3537a6a..9c8188d1 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5759,7 +5759,7 @@ } else if (len > this.__index__ + this.__vector__.length) { len = this.__index__ + this.__vector__.length; } - if (this.peek() === eof) { + if (this.peek_u8() === eof) { return eof; } return this.__vector__.slice(this.__index__, len); diff --git a/tests/ports.scm b/tests/ports.scm index 80e05d68..993a08da 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -110,7 +110,7 @@ (string->list (repr input))) (t.is (get-output-string port) input)))) -(test "port: write-char to output file" +(test "ports: write-char to output file" (lambda (t) (let ((filename "./tests/__x2__.scm")) (if (file-exists? filename) @@ -127,7 +127,7 @@ (delete-file filename) (t.is result input)))))) -(test "port: call-with-?-ports" +(test "ports: call-with-?-ports" (lambda (t) (let ((filename "./tests/__x3__.scm") (input '(hello world))) @@ -138,7 +138,7 @@ (delete-file filename) (t.is result input))))) -(test "port: close-output-port for output-string" +(test "ports: close-output-port for output-string" (lambda (t) (let ((input '(hello))) (let ((p (open-output-string))) @@ -149,7 +149,7 @@ (t.is (output-port-open? p) false) (t.is (get-output-string p) (repr input)))))) -(test "port: close-output-port for output-file" +(test "ports: close-output-port for output-file" (lambda (t) (let ((input '(hello))) (let ((filename "./tests/__x4__.scm")) @@ -166,7 +166,7 @@ (delete-file filename)))))) -(test "port: close-input-port for input-string" +(test "ports: close-input-port for input-string" (lambda (t) (let* ((input '(hello)) (port (open-input-string (repr input)))) @@ -176,7 +176,7 @@ (t.is (to.throw (read port)) true) (t.is (input-port-open? port) false)))) -(test "port: close-input-port for input-file" +(test "ports: close-input-port for input-file" (lambda (t) (let* ((input '(hello)) (filename "./tests/__x5__.scm")) @@ -190,19 +190,19 @@ (t.is (input-port-open? port) false) (delete-file filename))))) -(test "port: read-string for input-string" +(test "ports: read-string for input-string" (lambda (t) (let ((p (open-input-string "123456"))) (t.is (list (read-string 2 p) (read-string 2 p) (read-string 10 p)) '("12" "34" "56"))))) -(test "port: open-input-bytevector" +(test "ports: open-input-bytevector" (lambda (t) (let ((p (open-input-bytevector #u8(#x10 #x20 #xFF #xFF #xFF)))) (t.is (binary-port? p) true) (t.is (textual-port? p) false)))) -(test "port: read from open-input-bytevector" +(test "ports: read from open-input-bytevector" (lambda (t) (let ((p (open-input-bytevector #u8(#x10 #x20 #xFF #xFF #xFF)))) (t.is (peek-u8 p) #x10) @@ -215,7 +215,7 @@ (result.push (read-u8 p))) (t.is result #(#x20 #xFF #xFF #xFF)))))) -(test "port: textual-port?" +(test "ports: textual-port?" (lambda (t) (let* ((closable (list (open-input-file "./tests/ports.scm") (open-input-string "xxx") @@ -230,7 +230,7 @@ (for-each close-port closable) (delete-file "./tests/__x6__.scm")))) -(test "port: read binary" +(test "ports: read binary" (lambda (t) (let* ((fname "./tests/stubs/test.txt") (p (open-binary-input-file fname)) @@ -240,3 +240,9 @@ (result.push (string (integer->char (read-u8 p))))) (t.is (result.join "") (--> (fs.promises.readFile fname) (toString)))))) + +(test "ports: read bytevector" + (lambda (t) + (let ((p (open-binary-input-file "./tests/stubs/test.txt"))) + (t.is (utf8->string (read-bytevector 10 p)) + "Hello this")))) From ddc13fded3b55f2257f3d63af30e99710b8c04f5 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 09:35:20 +0100 Subject: [PATCH 061/109] close and u8-ready? for binary ports + small refactor #132 --- README.md | 4 +-- dist/lips.js | 92 ++++++++++++++++++++++++++++++++---------------- dist/lips.min.js | 4 +-- dist/std.min.scm | 9 +++-- dist/std.scm | 15 +++++++- lib/R7RS.scm | 15 +++++++- src/lips.js | 41 ++++++++++++++++----- tests/ports.scm | 14 +++++--- 8 files changed, 143 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 0c503f68..c980ff29 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&d005af547b59e83db4d531fc969a6e9d66f86c2a)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&ed932744444165faed2c85da45bc843d)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&ef950e218d00a98bc28f168e5fd6c294d60fc661)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&a9e5af3d68b1dad43711ebd41670f444)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index e728b43e..bc7ee7af 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 01 Mar 2021 18:29:03 +0000 + * build: Tue, 02 Mar 2021 08:30:00 +0000 */ (function () { 'use strict'; @@ -8708,6 +8708,17 @@ typecheck('InputPort', read, 'function'); read_only(this, '__type__', text_port); + var parser; + Object.defineProperty(this, '__parser__', { + enumerable: true, + get: function get() { + return parser; + }, + set: function set(value) { + typecheck('InputPort::__parser__', value, 'parser'); + parser = value; + } + }); this._read = read; this._with_parser = this._with_init_parser.bind(this, /*#__PURE__*/asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee9() { var line; @@ -8725,7 +8736,7 @@ case 3: line = _context9.sent; - _this6.__parser__ = new Parser(line, { + parser = new Parser(line, { env: _this6 }); @@ -8741,7 +8752,7 @@ }))); this.char_ready = function () { - return this.__parser__ && this.__parser__.__lexer__.peek() !== eof; + return !!this.__parser__ && this.__parser__.__lexer__.peek() !== eof; }; this._make_defaults(); @@ -8818,7 +8829,7 @@ InputPort.prototype.close = function () { var _this7 = this; - delete this.__parser__; // make content garbage collected, we assign null, + this.__parser__ = null; // make content garbage collected, we assign null, // because the value is in prototype this._with_parser = null; @@ -8897,7 +8908,7 @@ OutputStringPort.prototype = Object.create(OutputPort.prototype); OutputStringPort.prototype.toString = function () { - return '#<output-port <string>>'; + return '#<output-port (string)>'; }; OutputStringPort.prototype.getString = function () { @@ -8997,7 +9008,7 @@ InputStringPort.prototype.constructor = InputStringPort; InputStringPort.prototype.toString = function () { - return "#<input-port <string>>"; + return "#<input-port (string)>"; }; // ------------------------------------------------------------------------- @@ -9039,7 +9050,26 @@ InputByteVectorPort.prototype.constructor = InputByteVectorPort; InputByteVectorPort.prototype.toString = function () { - return "#<input-port <bytevector>>"; + return "#<input-port (bytevector)>"; + }; + + InputByteVectorPort.prototype.close = function () { + var _this12 = this; + + read_only(this, '__vector__', nil); + ['read_u8', 'close', 'peek_u8', 'read_u8_vector'].forEach(function (name) { + _this12[name] = 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 () { @@ -9092,7 +9122,7 @@ InputFilePort.prototype.constructor = InputFilePort; InputFilePort.prototype.toString = function () { - return "#<input-port ".concat(this.__filename__, ">"); + return "#<input-port (".concat(this.__filename__, ")>"); }; // ------------------------------------------------------------------------- @@ -9110,7 +9140,7 @@ InputBinaryFilePort.prototype.constructor = InputBinaryFilePort; InputBinaryFilePort.prototype.toString = function () { - return "#<input-binary-port ".concat(this.__filename__, ">"); + return "#<input-binary-port (".concat(this.__filename__, ")>"); }; // ------------------------------------------------------------------------- @@ -9351,13 +9381,13 @@ Environment.prototype.clone = function () { - var _this12 = this; + var _this13 = this; // duplicate refs var env = {}; // TODO: duplicated Symbols Object.keys(this.__env__).forEach(function (key) { - env[key] = _this12.__env__[key]; + env[key] = _this13.__env__[key]; }); return new Environment(env, this.__parent__, this.__name__); }; // ------------------------------------------------------------------------- @@ -9514,7 +9544,7 @@ Environment.prototype.constant = function (name, value) { - var _this13 = this; + var _this14 = this; if (this.__env__.hasOwnProperty(name)) { throw new Error("Environment::constant: ".concat(name, " already exists")); @@ -9523,7 +9553,7 @@ if (arguments.length === 1 && is_plain_object(arguments[0])) { var obj = arguments[0]; Object.keys(obj).forEach(function (key) { - _this13.constant(name, obj[key]); + _this14.constant(name, obj[key]); }); } else { Object.defineProperty(this.__env__, name, { @@ -9983,7 +10013,7 @@ }, "(cdr pair)\n\n Function returns cdr (tail) of the list/pair."), // ------------------------------------------------------------------ 'set!': doc(new Macro('set!', function (code) { - var _this14 = this; + var _this15 = this; var _ref28 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, dynamic_scope = _ref28.dynamic_scope, @@ -10058,7 +10088,7 @@ var key = parts.pop(); var name = parts.join('.'); - var obj = _this14.get(name, { + var obj = _this15.get(name, { throwError: false }); @@ -10563,7 +10593,7 @@ }, "(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."), // ------------------------------------------------------------------ 'eval': doc('eval', function (code, env) { - var _this15 = this; + var _this16 = this; env = env || this; return evaluate(code, { @@ -10571,13 +10601,13 @@ //dynamic_scope: this, error: function error(e) { var error = global_env.get('error'); - error.call(_this15, e.message); + error.call(_this16, e.message); if (e.code) { var stack = e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); }).join('\n'); - error.call(_this15, stack); + error.call(_this16, stack); } } }); @@ -11639,7 +11669,7 @@ }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ 'try': doc(new Macro('try', function (code, _ref38) { - var _this16 = this; + var _this17 = this; var dynamic_scope = _ref38.dynamic_scope, _error = _ref38.error; @@ -11673,9 +11703,9 @@ } var args = { - env: _this16, + env: _this17, error: function error(e) { - var env = _this16.inherit('try'); + var env = _this17.inherit('try'); if (catch_clause) { env.set(catch_clause.cdr.car.car, e); @@ -11685,7 +11715,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this16; + args.dynamic_scope = _this17; } unpromise(evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { @@ -11698,7 +11728,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this16; + args.dynamic_scope = _this17; } var result = evaluate(code.car, args); @@ -11758,7 +11788,7 @@ }, "(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."), // ------------------------------------------------------------------ map: doc(function map(fn) { - var _this17 = this; + var _this18 = this; for (var _len29 = arguments.length, lists = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { lists[_key29 - 1] = arguments[_key29]; @@ -11769,7 +11799,7 @@ lists.forEach(function (arg, i) { typecheck('map', arg, ['pair', 'nil'], i + 1); // detect cycles - if (arg instanceof Pair && !is_list.call(_this17, arg)) { + if (arg instanceof Pair && !is_list.call(_this18, arg)) { throw new Error("map: argument ".concat(i + 1, " is not a list")); } }); @@ -11791,7 +11821,7 @@ var env = this.newFrame(fn, args); env.set('parent.frame', parent_frame); return unpromise(fn.call.apply(fn, [env].concat(toConsumableArray(args))), function (head) { - return unpromise(map.call.apply(map, [_this17, fn].concat(toConsumableArray(lists.map(function (l) { + return unpromise(map.call.apply(map, [_this18, fn].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))), function (rest) { return new Pair(head, rest); @@ -11887,7 +11917,7 @@ }, "(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."), // ------------------------------------------------------------------ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { - var _this18 = this; + var _this19 = this; for (var _len32 = arguments.length, lists = new Array(_len32 > 3 ? _len32 - 3 : 0), _key33 = 3; _key33 < _len32; _key33++) { lists[_key33 - 3] = arguments[_key33]; @@ -11907,7 +11937,7 @@ return unpromise(fn.apply(void 0, toConsumableArray(lists.map(function (l) { return l.car; })).concat([init])), function (value) { - return reduce.call.apply(reduce, [_this18, fn, value].concat(toConsumableArray(lists.map(function (l) { + return reduce.call.apply(reduce, [_this19, fn, value].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))); }); @@ -13430,10 +13460,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 01 Mar 2021 18:29:03 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 02 Mar 2021 08:30:00 +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('Mon, 01 Mar 2021 18:29:03 +0000').valueOf(); + var date = LString('Tue, 02 Mar 2021 08:30:00 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13473,7 +13503,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Mon, 01 Mar 2021 18:29:03 +0000', + date: 'Tue, 02 Mar 2021 08:30:00 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 8d8e2715..40da88bf 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 01 Mar 2021 18:29:03 +0000 + * build: Tue, 02 Mar 2021 08:30:00 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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);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;n.__parser__=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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;delete this.__parser__;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port <string>>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port <string>>"};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"#<input-port <bytevector>>"};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 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"#<input-port ".concat(this.__filename__,">")};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"#<input-binary-port ".concat(this.__filename__,">")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Mon, 01 Mar 2021 18:29:03 +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,") <https://lips.js.org>\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:"Mon, 01 Mar 2021 18:29:03 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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, 02 Mar 2021 08:30:00 +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,") <https://lips.js.org>\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, 02 Mar 2021 08:30:00 +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,InputBinaryFilePort:InputBinaryFilePort,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/dist/std.min.scm b/dist/std.min.scm index ec0f8ea0..42ba7606 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -671,7 +671,7 @@ user need to provide global fs variable that is instance of FS interface." (let Function test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary"))))(define (textual-port? port) "(textual-port? port) -Function test if argument is string port." (and (port? port) (eq? port.__type__ (Symbol.for "text"))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port"))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) +Function test if argument is string port." (and (port? port) (eq? port.__type__ (Symbol.for "text"))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port. Binary port required."))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) (peek-u8 port) Return next byte from input-binary port. If there are no more bytes @@ -679,7 +679,12 @@ it return eof object." (lambda (port) (port.peek_u8)))(%define-binary-input-lamb (read-u8 port) Read next byte from input-binary port. If there are no more bytes -it return eof object." (lambda (port) (port.read_u8)))(define (read-bytevector k . rest) "(read-bytevector k) +it return eof object." (lambda (port) (port.read_u8)))(%define-binary-input-lambda u8-ready? "(u8-ready?) +(u8-ready? port) + +Returns #t if a byte is ready on the binary input port and returns #f otherwise. +If u8-ready? returns #t then the next read-u8 operation on the given port is +guaranteed not to hang. If the port is at end of file then u8-ready? returns #t." (lambda (port) (port.u8_ready)))(define (read-bytevector k . rest) "(read-bytevector k) (read-bytevector k port) Read next n bytes from input-binary port. If there are no more bytes diff --git a/dist/std.scm b/dist/std.scm index ee076b78..f70b902e 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3422,7 +3422,8 @@ (car rest)))) (typecheck ,name-str ,port "input-port") (if (not (binary-port? ,port)) - (throw (new Error (string-append ,name-str " invalid port"))) + (throw (new Error (string-append ,name-str + " invalid port. Binary port required."))) (,fn ,port)))))) ;; ----------------------------------------------------------------------------- @@ -3447,6 +3448,18 @@ (lambda (port) (port.read_u8))) +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + u8-ready? + "(u8-ready?) + (u8-ready? port) + + Returns #t if a byte is ready on the binary input port and returns #f otherwise. + If u8-ready? returns #t then the next read-u8 operation on the given port is + guaranteed not to hang. If the port is at end of file then u8-ready? returns #t." + (lambda (port) + (port.u8_ready))) + ;; ----------------------------------------------------------------------------- (define (read-bytevector k . rest) "(read-bytevector k) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 561ecb73..666821b6 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -636,7 +636,8 @@ (car rest)))) (typecheck ,name-str ,port "input-port") (if (not (binary-port? ,port)) - (throw (new Error (string-append ,name-str " invalid port"))) + (throw (new Error (string-append ,name-str + " invalid port. Binary port required."))) (,fn ,port)))))) ;; ----------------------------------------------------------------------------- @@ -661,6 +662,18 @@ (lambda (port) (port.read_u8))) +;; ----------------------------------------------------------------------------- +(%define-binary-input-lambda + u8-ready? + "(u8-ready?) + (u8-ready? port) + + Returns #t if a byte is ready on the binary input port and returns #f otherwise. + If u8-ready? returns #t then the next read-u8 operation on the given port is + guaranteed not to hang. If the port is at end of file then u8-ready? returns #t." + (lambda (port) + (port.u8_ready))) + ;; ----------------------------------------------------------------------------- (define (read-bytevector k . rest) "(read-bytevector k) diff --git a/src/lips.js b/src/lips.js index 9c8188d1..f040fa13 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5517,16 +5517,27 @@ } typecheck('InputPort', read, 'function'); read_only(this, '__type__', text_port); + var parser; + Object.defineProperty(this, '__parser__', { + enumerable: true, + get: function() { + return parser; + }, + set: function(value) { + typecheck('InputPort::__parser__', value, 'parser'); + parser = value; + } + }); this._read = read; this._with_parser = this._with_init_parser.bind(this, async () => { if (!this.char_ready()) { const line = await this._read(); - this.__parser__ = new Parser(line, { env: this }); + parser = new Parser(line, { env: this }); } return this.__parser__; }); this.char_ready = function() { - return this.__parser__ && this.__parser__.__lexer__.peek() !== eof; + return !!this.__parser__ && this.__parser__.__lexer__.peek() !== eof; }; this._make_defaults(); } @@ -5562,7 +5573,7 @@ return this._with_parser !== null; }; InputPort.prototype.close = function() { - delete this.__parser__; + this.__parser__ = null; // make content garbage collected, we assign null, // because the value is in prototype this._with_parser = null; @@ -5625,7 +5636,7 @@ } OutputStringPort.prototype = Object.create(OutputPort.prototype); OutputStringPort.prototype.toString = function() { - return '#<output-port <string>>'; + return '#<output-port (string)>'; }; OutputStringPort.prototype.getString = function() { return this._buffer.map(x => x.valueOf()).join(''); @@ -5699,7 +5710,7 @@ InputStringPort.prototype = Object.create(InputPort.prototype); InputStringPort.prototype.constructor = InputStringPort; InputStringPort.prototype.toString = function() { - return `#<input-port <string>>`; + return `#<input-port (string)>`; }; // ------------------------------------------------------------------------- function InputByteVectorPort(bytevectors) { @@ -5735,7 +5746,21 @@ InputByteVectorPort.prototype = Object.create(InputPort.prototype); InputByteVectorPort.prototype.constructor = InputByteVectorPort; InputByteVectorPort.prototype.toString = function() { - return `#<input-port <bytevector>>`; + return `#<input-port (bytevector)>`; + }; + InputByteVectorPort.prototype.close = function() { + read_only(this, '__vector__', nil); + ['read_u8', 'close', 'peek_u8', 'read_u8_vector'].forEach(name => { + this[name] = 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) { @@ -5777,7 +5802,7 @@ InputFilePort.prototype = Object.create(InputStringPort.prototype); InputFilePort.prototype.constructor = InputFilePort; InputFilePort.prototype.toString = function() { - return `#<input-port ${this.__filename__}>`; + return `#<input-port (${this.__filename__})>`; }; // ------------------------------------------------------------------------- function InputBinaryFilePort(content, filename) { @@ -5792,7 +5817,7 @@ InputBinaryFilePort.prototype = Object.create(InputByteVectorPort.prototype); InputBinaryFilePort.prototype.constructor = InputBinaryFilePort; InputBinaryFilePort.prototype.toString = function() { - return `#<input-binary-port ${this.__filename__}>`; + return `#<input-binary-port (${this.__filename__})>`; }; // ------------------------------------------------------------------------- const binary_port = Symbol.for('binary'); diff --git a/tests/ports.scm b/tests/ports.scm index 993a08da..09cb1889 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -38,9 +38,14 @@ (test "ports: port repr" (lambda (t) (t.is (repr (current-input-port)) "#<input-port>") - (t.is (repr (open-input-string "xxx")) "#<input-port <string>>") - (t.is (repr (open-input-string "xxx")) "#<input-port <string>>") - (t.is (repr (open-input-file "./tests/ports.scm")) "#<input-port ./tests/ports.scm>"))) + (t.is (repr (open-input-string "xxx")) "#<input-port (string)>") + (t.is (repr (open-input-string "xxx")) "#<input-port (string)>") + (t.is (repr (open-input-file "./tests/ports.scm")) + "#<input-port (./tests/ports.scm)>") + (t.is (repr (open-binary-input-file "./tests/ports.scm")) + "#<input-binary-port (./tests/ports.scm)>") + (t.is (repr (open-input-bytevector #u8(10))) + "#<input-port (bytevector)>"))) (test "ports: syntax extensions" (lambda (t) @@ -76,7 +81,8 @@ (define f (open-input-file "./tests/ports.scm")) (read f) (close-input-port f) - (t.is (repr (open-input-file "./tests/ports.scm")) "#<input-port ./tests/ports.scm>") + (t.is (repr (open-input-file "./tests/ports.scm")) + "#<input-port (./tests/ports.scm)>") (t.is (to.throw (read f)) true))) (test "ports: with-input-from-file" From 427c4f941970fc655ed7ad7a2d8a15d6593ecf3d Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 09:38:56 +0100 Subject: [PATCH 062/109] (deps) update prismjs --- package-lock.json | 8 ++++---- package.json | 2 +- templates/package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25235f11..9f521119 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@jcubic/lips", - "version": "1.0.0-beta.10", + "version": "1.0.0-beta.11", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -8298,9 +8298,9 @@ } }, "prismjs": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.22.0.tgz", - "integrity": "sha512-lLJ/Wt9yy0AiSYBf212kK3mM5L8ycwlyTlSxHBAneXLR0nzFMlZ5y7riFPF3E33zXOF2IH95xdY5jIyZbM9z/w==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.23.0.tgz", + "integrity": "sha512-c29LVsqOaLbBHuIbsTxaKENh1N2EQBOHaWv7gkHN4dgRbxSREqDnDbtFJYdpPauS4YCplMSNCABQ6Eeor69bAA==", "requires": { "clipboard": "^2.0.0" } diff --git a/package.json b/package.json index d7284640..556d0df1 100644 --- a/package.json +++ b/package.json @@ -230,6 +230,6 @@ "@jcubic/lily": "^0.1.0", "bn.js": "^4.11.8", "prism-cli": "^0.5.0", - "prismjs": "^1.22.0" + "prismjs": "^1.23.0" } } diff --git a/templates/package.json b/templates/package.json index b4149f1e..908b727a 100755 --- a/templates/package.json +++ b/templates/package.json @@ -230,6 +230,6 @@ "@jcubic/lily": "^0.1.0", "bn.js": "^4.11.8", "prism-cli": "^0.5.0", - "prismjs": "^1.22.0" + "prismjs": "^1.23.0" } } From 857111d6fac81d841a631629a0ed065c0b5f254a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 09:53:46 +0100 Subject: [PATCH 063/109] update unit tests #132 --- dist/lips.js | 8 ++++---- tests/ports.scm | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dist/lips.js b/dist/lips.js index bc7ee7af..4231ac01 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 02 Mar 2021 08:30:00 +0000 + * build: Tue, 02 Mar 2021 08:52:14 +0000 */ (function () { 'use strict'; @@ -13460,10 +13460,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 02 Mar 2021 08:30:00 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 02 Mar 2021 08:52:14 +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, 02 Mar 2021 08:30:00 +0000').valueOf(); + var date = LString('Tue, 02 Mar 2021 08:52:14 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13503,7 +13503,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 02 Mar 2021 08:30:00 +0000', + date: 'Tue, 02 Mar 2021 08:52:14 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/tests/ports.scm b/tests/ports.scm index 09cb1889..f6d2104e 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -219,7 +219,8 @@ (let ((result (vector))) (while (not (eof-object? (peek-u8 p))) (result.push (read-u8 p))) - (t.is result #(#x20 #xFF #xFF #xFF)))))) + (t.is result #(#x20 #xFF #xFF #xFF)) + (t.is (eof-object? (peek-u8 p)) true))))) (test "ports: textual-port?" (lambda (t) From c8b7bc3ad7b3b31ab4f69e17dd28b11ae57688c4 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 16:43:15 +0100 Subject: [PATCH 064/109] fix parsing regex Fix single slash in class brackets (`#/\/[^/]+$/`) slash in brackets was chaning the state to non regex The fix is to add another state for brackets --- CHANGELOG.md | 1 + dist/lips.js | 11 ++++++----- dist/lips.min.js | 4 ++-- src/lips.js | 3 +++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd00c1ec..a58e03d4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ * fix `exact->inexact` on complex numbers * fix arithmetic with single complex value * fix parsing regex that have escape slash and parenthesis (`#/( \\/)/g`) +* fix parsing regex that have single slash in class brackets (`#/\/[^/]+$/`) ## 1.0.0-beta.11 ### Breaking diff --git a/dist/lips.js b/dist/lips.js index 4231ac01..57b08093 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 02 Mar 2021 08:52:14 +0000 + * build: Tue, 02 Mar 2021 15:40:21 +0000 */ (function () { 'use strict'; @@ -2677,6 +2677,7 @@ Lexer.symbol = Symbol["for"]('symbol'); Lexer.comment = Symbol["for"]('comment'); Lexer.regex = Symbol["for"]('regex'); + Lexer.regex_class = Symbol["for"]('regex_class'); Lexer.character = Symbol["for"]('character'); Lexer.bracket = Symbol["for"]('bracket'); Lexer.b_symbol = Symbol["for"]('b_symbol'); @@ -2698,7 +2699,7 @@ [/#/, null, /[bdxoeitf]/i, null, Lexer.symbol], // characters [/#/, null, /\\/, null, Lexer.character], [/\\/, /#/, /\s/, Lexer.character, Lexer.character], [/\\/, /#/, /[()[\]]/, Lexer.character, Lexer.character], [/\s/, /\\/, null, Lexer.character, null], [/\S/, null, Lexer.boundary, Lexer.character, null], // brackets [/[()[\]]/, null, null, null, null], // regex - [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null]]; // ---------------------------------------------------------------------- + [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], [/\[/, null, null, Lexer.regex, Lexer.regex_class], [/\]/, /[^\\]/, null, Lexer.regex_class, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, Lexer.boundary, Lexer.regex, null], [/[gimyus]/, /\//, /[gimyus]/, Lexer.regex, Lexer.regex], [/[gimyus]/, /[gimyus]/, Lexer.boundary, Lexer.regex, null]]; // ---------------------------------------------------------------------- // :: symbols should be matched last // ---------------------------------------------------------------------- @@ -13460,10 +13461,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 02 Mar 2021 08:52:14 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 02 Mar 2021 15:40:21 +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, 02 Mar 2021 08:52:14 +0000').valueOf(); + var date = LString('Tue, 02 Mar 2021 15:40:21 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13503,7 +13504,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 02 Mar 2021 08:52:14 +0000', + date: 'Tue, 02 Mar 2021 15:40:21 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 40da88bf..1419736f 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 02 Mar 2021 08:30:00 +0000 + * build: Tue, 02 Mar 2021 15:40:21 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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, 02 Mar 2021 08:30:00 +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,") <https://lips.js.org>\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, 02 Mar 2021 08:30:00 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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, 02 Mar 2021 15:40:21 +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,") <https://lips.js.org>\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, 02 Mar 2021 15:40:21 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index f040fa13..559477c9 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1163,6 +1163,7 @@ Lexer.symbol = Symbol.for('symbol'); Lexer.comment = Symbol.for('comment'); Lexer.regex = Symbol.for('regex'); + Lexer.regex_class = Symbol.for('regex_class'); Lexer.character = Symbol.for('character'); Lexer.bracket = Symbol.for('bracket'); Lexer.b_symbol = Symbol.for('b_symbol'); @@ -1215,6 +1216,8 @@ // regex [/#/, Lexer.boundary, /\//, null, Lexer.regex], [/[ \t]/, null, null, Lexer.regex, Lexer.regex], + [/\[/, null, null, Lexer.regex, Lexer.regex_class], + [/\]/, /[^\\]/, null, Lexer.regex_class, Lexer.regex], [/[()[\]]/, null, null, Lexer.regex, Lexer.regex], [/\//, /\\/, null, Lexer.regex, Lexer.regex], [/\//, /[^#]/, Lexer.boundary, Lexer.regex, null], From d36f72988cf7ed2ae58cc90f4740711c8b8ef2cc Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 16:45:41 +0100 Subject: [PATCH 065/109] add current-directory and set-... from SRFI-170 --- CHANGELOG.md | 1 + README.md | 4 +- dist/std.min.scm | 11 +++- dist/std.scm | 137 ++++++++++++++++++++++++++++------------------ lib/R7RS.scm | 32 +++++++++++ lib/bootstrap.scm | 105 ++++++++++++++++++----------------- 6 files changed, 181 insertions(+), 109 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58e03d4..6828aa3d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ * add `+nan.0` and `-nan.0` (R7RS) * properly handle negative inexact zero * new `environment?` function +* add `current-directory` and `set-...` from SRFI-170 ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/README.md b/README.md index c980ff29..b0c2b282 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&ef950e218d00a98bc28f168e5fd6c294d60fc661)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&a9e5af3d68b1dad43711ebd41670f444)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&857111d6fac81d841a631629a0ed065c0b5f254a)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&adef7a32efa92798c218d1517ddd0082)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/std.min.scm b/dist/std.min.scm index 42ba7606..54681bdb 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -753,4 +753,13 @@ Macro for importing names from library." (let ((parent (current-environment))) ( Create new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib))(define (%export module namespace specs) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) specs)))))(define-macro (define-library spec . body) "(define-library (library (name namespace) . body) Macro for defining modules inside you can use define to create functions. -And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) \ No newline at end of file +And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var)))))))(define-values (current-directory set-current-directory!) (if (eq? self window) (let ((cwd (string-append location.origin (--> location.pathname (replace #/\/[^/]+$/ "/"))))) (values (lambda () "(current-directory) + +Return corrent working directory, default it's corrent URL." cwd) (lambda (value) "(set-current-directory! string) + +Function change current working directory to provided string." (typecheck "set-current-directory!" value "string") (set! cwd value)))) (let ((process (require "process"))) (values (lambda () "(current-directory) + +Return corrent working directory, default it's path from where +the script was executed." (string-append (process.cwd) "/")) (lambda (value) "(set-current-directory! string) + +Function change current working directory to provided string." (typecheck "set-current-directory!" value "string") (process.chdir value)))))) \ No newline at end of file diff --git a/dist/std.scm b/dist/std.scm index f70b902e..ad242a6e 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -170,7 +170,7 @@ expr `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (plain-object? x) "(plain-object? x) @@ -178,7 +178,7 @@ ;; here we don't use string=? or equal? because it may not be defined (and (== (--> (type x) (cmp "object")) 0) (eq? (. x 'constructor) Object))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) @@ -378,7 +378,7 @@ (append (array->list (--> names (map (unary string->symbol)))) (dir (Object.getPrototypeOf obj) true))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (tree-map f tree) "(tree-map fn tree) @@ -676,7 +676,7 @@ nil (cons (map car args) (apply zip (map cdr args)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (promise . body) "(promise . body) @@ -686,7 +686,7 @@ (catch (e) (error (.. e.message))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (timer time . body) "(timer time . body) @@ -694,14 +694,14 @@ native JS clearTimeout function." `(setTimeout (lambda () (try (begin ,@body) (catch (e) (error (.. e.message))))) ,time)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (defmacro? obj) "(defmacro? expression) Function check if object is macro and it's expandable." (and (macro? obj) (. obj 'defmacro))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (n-ary n fn) "(n-ary n fn) @@ -709,7 +709,7 @@ (lambda args (apply fn (take n args)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (take n lst) "(take n list) @@ -719,21 +719,21 @@ (reverse result) (iter (cons (car lst) result) (- i 1) (cdr lst))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define unary (%doc "(unary fn) Function return new function with arguments limited to one." (curry n-ary 1))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define binary (%doc "(binary fn) Function return new function with arguments limited to two." (curry n-ary 2))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- ;; LIPS Object System -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%class-lambda expr) "(class-lambda expr) @@ -756,7 +756,7 @@ `(lambda (,@args) (,(cadr expr) this ,@args)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%class-method-name expr) "(%class-method-name expr) @@ -765,7 +765,7 @@ (car expr) (list 'quote expr))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (define-class name parent . body) "(define-class name parent . body) @@ -802,7 +802,7 @@ (iter functions item (cdr lst)) (iter (cons item functions) constructor (cdr lst))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax class (syntax-rules () ((_) @@ -815,7 +815,7 @@ Macro allow to create anonymous classes. See define-class for details.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (make-tags expr) "(make-tags expression) @@ -830,7 +830,7 @@ `(list->array (list ,@(map make-tags (cdaddr expr)))) (caddr expr))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%sxml h expr) "(%sxml h expr) @@ -862,7 +862,7 @@ rest) (list first))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (pragma->sxml pragma) `(define-macro (sxml expr) "(sxml expr) @@ -876,10 +876,10 @@ (span \"world\")))" (%sxml ',pragma expr))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (pragma->sxml h) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (with-tags expr) "(with-tags expression) @@ -895,7 +895,7 @@ To get the string from the macro you can use vhtml library from npm." (make-tags expr)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (get-script url) "(get-script url) @@ -912,28 +912,28 @@ (if document.head (document.head.appendChild script))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (gensym? value) "(gensym? value) Function return #t if value is symbol and it's gensym. It returns #f otherwise." (and (symbol? value) (--> value (is_gensym)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (degree->radians x) "(degree->radians x) Convert degree to radians." (* x (/ Math.PI 180))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (radians->degree x) "(radians->degree x) Convert radians to degree." (* x (/ 180 Math.PI))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax while (syntax-rules () ((_ predicate body ...) @@ -944,7 +944,7 @@ Macro that create a loop, it exectue body until cond expression is false.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax ++ (syntax-rules () ((++ x) @@ -955,7 +955,7 @@ Macro that work only on variables and increment the value by one.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax -- (syntax-rules () ((-- x) @@ -966,7 +966,7 @@ Macro that decrement the value it work only on symbols") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (pretty-format pair) "(pretty-format pair) @@ -974,7 +974,7 @@ (typecheck "pretty-pair" pair "pair") (--> (new lips.Formatter (repr pair true)) (break) (format))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (reset) "(reset) @@ -986,14 +986,14 @@ (if (not (--> defaults (includes name))) (--> env (unset name))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (make-list n . rest) (if (or (not (integer? n)) (<= n 0)) (throw (new Error "make-list: first argument need to be integer larger then 0")) (let ((fill (if (null? rest) undefined (car rest)))) (array->list (--> (new Array n) (fill fill)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (range n) "(range n) @@ -1001,7 +1001,7 @@ (typecheck "range" n "number") (array->list (--> (new Array n) (fill 0) (map (lambda (_ i) i))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (do-iterator spec cond . body) "(do-iterator (var expr) (test) body ...) @@ -1040,21 +1040,21 @@ (set! ,item (,next)) (set! ,name (. ,item "value"))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-repr! Set (lambda () "#<Set>")) (set-repr! Map (lambda () "#<Met>")) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (native-symbol? x) "(native-symbol? object) Function check if value is JavaScript symbol." (and (string=? (type x) "symbol") (not (symbol? x)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-special! "’" 'warn-quote) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (warn-quote) "(warn-quote) @@ -1063,7 +1063,7 @@ "(set-special! \"’\" 'quote)" " to allow running this type of quote")))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (quote-promise expr) "(quote-promise expr) '>expr @@ -1076,13 +1076,13 @@ (env.set (Symbol.for "__promise__") true) ,expr)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body) @@ -1095,7 +1095,7 @@ spec) ,@body)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (let-std spec . body) "(let-std ((name var)) . body) @@ -1105,7 +1105,7 @@ from interaction-environment." `(let-env-values lips.env.__parent__ ,spec ,@body)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (apropos name) "(apropos name) @@ -1119,14 +1119,14 @@ (else name)) (env)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- ;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-special! "#," 'sharp-comma) (define **reader-ctor-list** '()) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) @@ -1134,7 +1134,7 @@ (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) @@ -1157,7 +1157,7 @@ (resolve data) (reject err)))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (list* . args) "(list* arg1 ...) @@ -1169,7 +1169,7 @@ args) (map await (vector->list ,result))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (%not-implemented name) "(not-implemented name) @@ -1179,7 +1179,7 @@ ,(string-append "(" str-name ")\n\nThis function is not yet implemented.") (throw (new Error ,(string-append str-name " has not beed implemented")))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (%make-env name . names) "(%make-env name f1 f2 ...) @@ -1195,7 +1195,7 @@ null ,name)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define Y (lambda (h) "(Y f) @@ -1212,7 +1212,7 @@ (lambda (g) (h (lambda args (apply (g g) args))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) @@ -1226,14 +1226,13 @@ (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (environment? obj) "(environment? obj) Function check if object is LIPS environment." (instanceof lips.Environment obj)) - -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ ;; | | \ \ | | | || . \/ __> | | @@ -3807,3 +3806,35 @@ (--> ,parent (set ',name ,module-var))))) ;; ----------------------------------------------------------------------------- +(define-values (current-directory set-current-directory!) + (if (eq? self window) + (let ((cwd (string-append location.origin (--> location.pathname + (replace #/\/[^/]+$/ "/"))))) + (values + (lambda () + "(current-directory) + + Return corrent working directory, default it's corrent URL." + cwd) + (lambda (value) + "(set-current-directory! string) + + Function change current working directory to provided string." + (typecheck "set-current-directory!" value "string") + (set! cwd value)))) + (let ((process (require "process"))) + (values + (lambda () + "(current-directory) + + Return corrent working directory, default it's path from where + the script was executed." + (string-append (process.cwd) "/")) + (lambda (value) + "(set-current-directory! string) + + Function change current working directory to provided string." + (typecheck "set-current-directory!" value "string") + (process.chdir value)))))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 666821b6..b212734b 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -1021,3 +1021,35 @@ (--> ,parent (set ',name ,module-var))))) ;; ----------------------------------------------------------------------------- +(define-values (current-directory set-current-directory!) + (if (eq? self window) + (let ((cwd (string-append location.origin (--> location.pathname + (replace #/\/[^/]+$/ "/"))))) + (values + (lambda () + "(current-directory) + + Return corrent working directory, default it's corrent URL." + cwd) + (lambda (value) + "(set-current-directory! string) + + Function change current working directory to provided string." + (typecheck "set-current-directory!" value "string") + (set! cwd value)))) + (let ((process (require "process"))) + (values + (lambda () + "(current-directory) + + Return corrent working directory, default it's path from where + the script was executed." + (string-append (process.cwd) "/")) + (lambda (value) + "(set-current-directory! string) + + Function change current working directory to provided string." + (typecheck "set-current-directory!" value "string") + (process.chdir value)))))) + +;; ----------------------------------------------------------------------------- diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index cab6db40..144f5954 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -170,7 +170,7 @@ expr `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (plain-object? x) "(plain-object? x) @@ -178,7 +178,7 @@ ;; here we don't use string=? or equal? because it may not be defined (and (== (--> (type x) (cmp "object")) 0) (eq? (. x 'constructor) Object))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) @@ -378,7 +378,7 @@ (append (array->list (--> names (map (unary string->symbol)))) (dir (Object.getPrototypeOf obj) true))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (tree-map f tree) "(tree-map fn tree) @@ -676,7 +676,7 @@ nil (cons (map car args) (apply zip (map cdr args)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (promise . body) "(promise . body) @@ -686,7 +686,7 @@ (catch (e) (error (.. e.message))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (timer time . body) "(timer time . body) @@ -694,14 +694,14 @@ native JS clearTimeout function." `(setTimeout (lambda () (try (begin ,@body) (catch (e) (error (.. e.message))))) ,time)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (defmacro? obj) "(defmacro? expression) Function check if object is macro and it's expandable." (and (macro? obj) (. obj 'defmacro))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (n-ary n fn) "(n-ary n fn) @@ -709,7 +709,7 @@ (lambda args (apply fn (take n args)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (take n lst) "(take n list) @@ -719,21 +719,21 @@ (reverse result) (iter (cons (car lst) result) (- i 1) (cdr lst))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define unary (%doc "(unary fn) Function return new function with arguments limited to one." (curry n-ary 1))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define binary (%doc "(binary fn) Function return new function with arguments limited to two." (curry n-ary 2))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- ;; LIPS Object System -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%class-lambda expr) "(class-lambda expr) @@ -756,7 +756,7 @@ `(lambda (,@args) (,(cadr expr) this ,@args)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%class-method-name expr) "(%class-method-name expr) @@ -765,7 +765,7 @@ (car expr) (list 'quote expr))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (define-class name parent . body) "(define-class name parent . body) @@ -802,7 +802,7 @@ (iter functions item (cdr lst)) (iter (cons item functions) constructor (cdr lst))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax class (syntax-rules () ((_) @@ -815,7 +815,7 @@ Macro allow to create anonymous classes. See define-class for details.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (make-tags expr) "(make-tags expression) @@ -830,7 +830,7 @@ `(list->array (list ,@(map make-tags (cdaddr expr)))) (caddr expr))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (%sxml h expr) "(%sxml h expr) @@ -862,7 +862,7 @@ rest) (list first))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (pragma->sxml pragma) `(define-macro (sxml expr) "(sxml expr) @@ -876,10 +876,10 @@ (span \"world\")))" (%sxml ',pragma expr))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (pragma->sxml h) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (with-tags expr) "(with-tags expression) @@ -895,7 +895,7 @@ To get the string from the macro you can use vhtml library from npm." (make-tags expr)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (get-script url) "(get-script url) @@ -912,28 +912,28 @@ (if document.head (document.head.appendChild script))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (gensym? value) "(gensym? value) Function return #t if value is symbol and it's gensym. It returns #f otherwise." (and (symbol? value) (--> value (is_gensym)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (degree->radians x) "(degree->radians x) Convert degree to radians." (* x (/ Math.PI 180))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (radians->degree x) "(radians->degree x) Convert radians to degree." (* x (/ 180 Math.PI))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax while (syntax-rules () ((_ predicate body ...) @@ -944,7 +944,7 @@ Macro that create a loop, it exectue body until cond expression is false.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax ++ (syntax-rules () ((++ x) @@ -955,7 +955,7 @@ Macro that work only on variables and increment the value by one.") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax -- (syntax-rules () ((-- x) @@ -966,7 +966,7 @@ Macro that decrement the value it work only on symbols") -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (pretty-format pair) "(pretty-format pair) @@ -974,7 +974,7 @@ (typecheck "pretty-pair" pair "pair") (--> (new lips.Formatter (repr pair true)) (break) (format))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (reset) "(reset) @@ -986,14 +986,14 @@ (if (not (--> defaults (includes name))) (--> env (unset name))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (make-list n . rest) (if (or (not (integer? n)) (<= n 0)) (throw (new Error "make-list: first argument need to be integer larger then 0")) (let ((fill (if (null? rest) undefined (car rest)))) (array->list (--> (new Array n) (fill fill)))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (range n) "(range n) @@ -1001,7 +1001,7 @@ (typecheck "range" n "number") (array->list (--> (new Array n) (fill 0) (map (lambda (_ i) i))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (do-iterator spec cond . body) "(do-iterator (var expr) (test) body ...) @@ -1040,21 +1040,21 @@ (set! ,item (,next)) (set! ,name (. ,item "value"))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-repr! Set (lambda () "#<Set>")) (set-repr! Map (lambda () "#<Met>")) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (native-symbol? x) "(native-symbol? object) Function check if value is JavaScript symbol." (and (string=? (type x) "symbol") (not (symbol? x)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-special! "’" 'warn-quote) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (warn-quote) "(warn-quote) @@ -1063,7 +1063,7 @@ "(set-special! \"’\" 'quote)" " to allow running this type of quote")))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (quote-promise expr) "(quote-promise expr) '>expr @@ -1076,13 +1076,13 @@ (env.set (Symbol.for "__promise__") true) ,expr)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body) @@ -1095,7 +1095,7 @@ spec) ,@body)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (let-std spec . body) "(let-std ((name var)) . body) @@ -1105,7 +1105,7 @@ from interaction-environment." `(let-env-values lips.env.__parent__ ,spec ,@body)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (apropos name) "(apropos name) @@ -1119,14 +1119,14 @@ (else name)) (env)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- ;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (set-special! "#," 'sharp-comma) (define **reader-ctor-list** '()) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) @@ -1134,7 +1134,7 @@ (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) @@ -1157,7 +1157,7 @@ (resolve data) (reject err)))))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (list* . args) "(list* arg1 ...) @@ -1169,7 +1169,7 @@ args) (map await (vector->list ,result))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (%not-implemented name) "(not-implemented name) @@ -1179,7 +1179,7 @@ ,(string-append "(" str-name ")\n\nThis function is not yet implemented.") (throw (new Error ,(string-append str-name " has not beed implemented")))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define-macro (%make-env name . names) "(%make-env name f1 f2 ...) @@ -1195,7 +1195,7 @@ null ,name)) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define Y (lambda (h) "(Y f) @@ -1212,7 +1212,7 @@ (lambda (g) (h (lambda args (apply (g g) args))))))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) @@ -1226,11 +1226,10 @@ (if (not (null? fs)) (--> lips.env (get '**internal-env**) (set "fs" fs)))) -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- (define (environment? obj) "(environment? obj) Function check if object is LIPS environment." (instanceof lips.Environment obj)) - -;; --------------------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- From 8cc7b30ab82869192a23294d603faabf3b5df836 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 2 Mar 2021 21:08:08 +0100 Subject: [PATCH 066/109] helper functions for reading binary/text files from url and fs #132 #134 --- dist/std.min.scm | 27 ++++++++++- dist/std.scm | 114 ++++++++++++++++++++++++++++++++++++++++++++++ lib/bootstrap.scm | 114 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+), 1 deletion(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index 54681bdb..ec459b12 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -272,7 +272,32 @@ throw exception that function is not yet implemented." (quasiquote (new lips.Env + |_| + /_/ \\_\\ + |_| + + |_| |_| + + + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define (environment? obj) "(environment? obj) -Function check if object is LIPS environment." (instanceof lips.Environment obj))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) +Function check if object is LIPS environment." (instanceof lips.Environment obj))(define %read-file (let ((readFile #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) + +Read file from url or file system. If binary is false it will return +string that contain all the content. For HTTP requests, If binary +is false it will: when in browser return ArrayBuffer and in Node +it will return Buffer object. When reading from file system +in both cases it will return Buffer objects. + +The code that use those function, in binary mode, need to check +if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not readFile) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (path binary) (let ((buff (_readFile path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (readFile path binary))) ((--> path (match #/^https?:\/\//)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path)))))))(define %read-binary-file (curry %read-file #t))(define %read-text-file (curry %read-file #f))(define (response->content binary res) "(response->text binary res) + +Function read all text from Node.js HTTP response object. If binary argument is +true it will return Buffer object that can be converted to u8vector. + +***Warrning:*** it may overflow the stack (part of Node) when converting +whole buffer to u8vector." (let ((result (vector))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" (lambda (chunk) (result.push (Buffer.from chunk "binary")))) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join "")))))))))(define response->buffer (curry response->content #t))(define response->text (curry response->content #f))(define http-get (if (eq? self window) (lambda (url binary) "(http-get url) + +Node.js Function that send HTTP Request and return string or +binary Buffer object." (throw (new Error "http-get: function is Node.js only."))) (let* ((http (. (require "http") (quote get))) (https (. (require "https") (quote get)))) (lambda (url binary) "(http-get url) + +Node.js Function that send HTTP Request and return string or +binary Buffer object." (let ((request (if (null? (url.match #/^https/)) http https))) (new Promise (lambda (resolve reject) (--> (request url (lambda (res) (if (= res.statusCode 200) (resolve (response->content binary res)) (let ((code res.statusCode)) (res.resume) (reject (string-append "Request return " (number->string code))))))) (on "error" reject)))))))))(define (buffer->u8vector bin) "(buffer->u8vector bin) + +Cross platform function that can be used in both Node and Browser. +It can be used together with %read-file or %read-binary-file and convert +the result ArrayBuffer or Buffer to u8vector." (if (instanceof ArrayBuffer bin) (new Uint8Array bin) (Uint8Array.from bin)))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) Macro that creates special symbol macro for evaluator similar to build in , or `. It's like alias for real macro. Similar to CL reader macros but it receive already diff --git a/dist/std.scm b/dist/std.scm index ad242a6e..c81806a0 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1232,6 +1232,120 @@ Function check if object is LIPS environment." (instanceof lips.Environment obj)) + +;; ----------------------------------------------------------------------------- +(define %read-file + (let ((readFile #f) (fetch-url #f)) + (lambda (binary path) + "(%read-file binary path) + + Read file from url or file system. If binary is false it will return + string that contain all the content. For HTTP requests, If binary + is false it will: when in browser return ArrayBuffer and in Node + it will return Buffer object. When reading from file system + in both cases it will return Buffer objects. + + The code that use those function, in binary mode, need to check + if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." + (if (not readFile) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-input-file: fs not defined")) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (path binary) + (let ((buff (_readFile path))) + (if binary + (if (eq? self window) + (new Blob (vector buff)) + buff) + (--> buff (toString)))))))))) + (if (not fetch-url) + (set! fetch-url (lambda (url binary) + (if (eq? self window) + (let ((res (fetch url))) + (if binary + (res.arrayBuffer) + (res.text))) + (http-get url binary))))) + (cond ((char=? (string-ref path 0) #\/) + (if (not (file-exists? path)) + (throw (new Error (string-append "file " + path + " don't exists"))) + (readFile path binary))) + ((--> path (match #/^https?:\/\//)) + (fetch-url path binary)) + (else + (%read-file binary (string-append (current-directory) path))))))) + +;; ----------------------------------------------------------------------------- +(define %read-binary-file (curry %read-file true)) +(define %read-text-file (curry %read-file false)) + +;; ----------------------------------------------------------------------------- +(define (response->content binary res) + "(response->text binary res) + + Function read all text from Node.js HTTP response object. If binary argument is + true it will return Buffer object that can be converted to u8vector. + + ***Warrning:*** it may overflow the stack (part of Node) when converting + whole buffer to u8vector." + (let ((result (vector))) + (res.setEncoding (if binary "binary" "utf8")) + (new Promise (lambda (resolve) + (res.on "data" (lambda (chunk) + (result.push (Buffer.from chunk "binary")))) + (res.on "end" (lambda () + (if binary + (resolve (Buffer.concat result)) + (resolve (result.join ""))))))))) + +;; ----------------------------------------------------------------------------- +(define response->buffer (curry response->content true)) +(define response->text (curry response->content false)) + +;; ----------------------------------------------------------------------------- +(define http-get + (if (eq? self window) + (lambda (url binary) + "(http-get url) + + Node.js Function that send HTTP Request and return string or + binary Buffer object." + (throw (new Error "http-get: function is Node.js only."))) + (let* ((http (. (require "http") 'get)) + (https (. (require "https") 'get))) + (lambda (url binary) + "(http-get url) + + Node.js Function that send HTTP Request and return string or + binary Buffer object." + (let ((request (if (null? (url.match #/^https/)) http https))) + (new Promise + (lambda (resolve reject) + (--> (request url + (lambda (res) + (if (= res.statusCode 200) + (resolve (response->content binary res)) + (let ((code res.statusCode)) + (res.resume) + (reject (string-append + "Request return " + (number->string code))))))) + (on "error" reject))))))))) + +;; ----------------------------------------------------------------------------- +(define (buffer->u8vector bin) + "(buffer->u8vector bin) + + Cross platform function that can be used in both Node and Browser. + It can be used together with %read-file or %read-binary-file and convert + the result ArrayBuffer or Buffer to u8vector." + (if (instanceof ArrayBuffer bin) + (new Uint8Array bin) + (Uint8Array.from bin))) + ;; ----------------------------------------------------------------------------- ;; __ __ __ ;; / / \ \ _ _ ___ ___ \ \ diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 144f5954..3d53ed42 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1232,4 +1232,118 @@ Function check if object is LIPS environment." (instanceof lips.Environment obj)) + +;; ----------------------------------------------------------------------------- +(define %read-file + (let ((readFile #f) (fetch-url #f)) + (lambda (binary path) + "(%read-file binary path) + + Read file from url or file system. If binary is false it will return + string that contain all the content. For HTTP requests, If binary + is false it will: when in browser return ArrayBuffer and in Node + it will return Buffer object. When reading from file system + in both cases it will return Buffer objects. + + The code that use those function, in binary mode, need to check + if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." + (if (not readFile) + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error "open-input-file: fs not defined")) + (let ((_readFile (promisify fs.readFile))) + (set! readFile (lambda (path binary) + (let ((buff (_readFile path))) + (if binary + (if (eq? self window) + (new Blob (vector buff)) + buff) + (--> buff (toString)))))))))) + (if (not fetch-url) + (set! fetch-url (lambda (url binary) + (if (eq? self window) + (let ((res (fetch url))) + (if binary + (res.arrayBuffer) + (res.text))) + (http-get url binary))))) + (cond ((char=? (string-ref path 0) #\/) + (if (not (file-exists? path)) + (throw (new Error (string-append "file " + path + " don't exists"))) + (readFile path binary))) + ((--> path (match #/^https?:\/\//)) + (fetch-url path binary)) + (else + (%read-file binary (string-append (current-directory) path))))))) + +;; ----------------------------------------------------------------------------- +(define %read-binary-file (curry %read-file true)) +(define %read-text-file (curry %read-file false)) + +;; ----------------------------------------------------------------------------- +(define (response->content binary res) + "(response->text binary res) + + Function read all text from Node.js HTTP response object. If binary argument is + true it will return Buffer object that can be converted to u8vector. + + ***Warrning:*** it may overflow the stack (part of Node) when converting + whole buffer to u8vector." + (let ((result (vector))) + (res.setEncoding (if binary "binary" "utf8")) + (new Promise (lambda (resolve) + (res.on "data" (lambda (chunk) + (result.push (Buffer.from chunk "binary")))) + (res.on "end" (lambda () + (if binary + (resolve (Buffer.concat result)) + (resolve (result.join ""))))))))) + +;; ----------------------------------------------------------------------------- +(define response->buffer (curry response->content true)) +(define response->text (curry response->content false)) + +;; ----------------------------------------------------------------------------- +(define http-get + (if (eq? self window) + (lambda (url binary) + "(http-get url) + + Node.js Function that send HTTP Request and return string or + binary Buffer object." + (throw (new Error "http-get: function is Node.js only."))) + (let* ((http (. (require "http") 'get)) + (https (. (require "https") 'get))) + (lambda (url binary) + "(http-get url) + + Node.js Function that send HTTP Request and return string or + binary Buffer object." + (let ((request (if (null? (url.match #/^https/)) http https))) + (new Promise + (lambda (resolve reject) + (--> (request url + (lambda (res) + (if (= res.statusCode 200) + (resolve (response->content binary res)) + (let ((code res.statusCode)) + (res.resume) + (reject (string-append + "Request return " + (number->string code))))))) + (on "error" reject))))))))) + +;; ----------------------------------------------------------------------------- +(define (buffer->u8vector bin) + "(buffer->u8vector bin) + + Cross platform function that can be used in both Node and Browser. + It can be used together with %read-file or %read-binary-file and convert + the result ArrayBuffer or Buffer to u8vector." + (if (instanceof ArrayBuffer bin) + (new Uint8Array bin) + (Uint8Array.from bin))) + ;; ----------------------------------------------------------------------------- From a5c8365ab6c9a1a4c4fa1b4f51cb4fdd7c91b85e Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 10:38:38 +0100 Subject: [PATCH 067/109] open-binary-input-file on urls #134 #132 + add docstrings --- dist/std.min.scm | 4 ++-- dist/std.scm | 21 ++++++--------------- lib/R7RS.scm | 33 ++++++++++++++++++--------------- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index ec459b12..39086bc8 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -689,10 +689,10 @@ and after finish get the whole string using `get-output-string`." (new lips.Outp Function get full string from string port. If nothing was wrote to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define (open-input-bytevector bytevector) "(open-input-bytevector bytevector) -Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define open-binary-input-file (let ((readFile #f)) (lambda (filename) "(open-binary-input-file filename) +Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define (open-binary-input-file filename) "(open-binary-input-file filename) Function return new Input Binary Port with given filename. In Browser -user need to provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-binary-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) (Uint8Array.from (_readFile filename)))))) (new lips.InputBinaryFilePort (readFile filename) filename)))))))(define (binary-port? port) "(binary-port? port) +user need to provide global fs variable that is instance of FS interface." (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) (new lips.InputBinaryFilePort u8vector filename)))(define (binary-port? port) "(binary-port? port) Function test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary"))))(define (textual-port? port) "(textual-port? port) diff --git a/dist/std.scm b/dist/std.scm index c81806a0..0caea33f 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3493,22 +3493,13 @@ (new lips.InputByteVectorPort bytevector)) ;; ----------------------------------------------------------------------------- -(define open-binary-input-file - (let ((readFile #f)) - (lambda(filename) - "(open-binary-input-file filename) +(define (open-binary-input-file filename) + "(open-binary-input-file filename) - Function return new Input Binary Port with given filename. In Browser - user need to provide global fs variable that is instance of FS interface." - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "open-binary-input-file: fs not defined")) - (begin - (if (not (procedure? readFile)) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (filename) - (Uint8Array.from (_readFile filename)))))) - (new lips.InputBinaryFilePort (readFile filename) filename))))))) + Function return new Input Binary Port with given filename. In Browser + user need to provide global fs variable that is instance of FS interface." + (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) + (new lips.InputBinaryFilePort u8vector filename))) ;; ----------------------------------------------------------------------------- (define (binary-port? port) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index b212734b..50de6d13 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -539,6 +539,12 @@ (define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) + "(string->utf8 string) + (string->utf8 string start) + (string->utf8 string start end) + + Function converts string into u8 bytevector using utf8 encoding. + The start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) @@ -550,6 +556,12 @@ (define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) + "(utf8->string u8vector) + (utf8->string u8vector start) + (utf8->string u8vector start end) + + Function converts u8 bytevector into string using utf8 encoding. + The start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) @@ -594,22 +606,13 @@ (new lips.InputByteVectorPort bytevector)) ;; ----------------------------------------------------------------------------- -(define open-binary-input-file - (let ((readFile #f)) - (lambda(filename) - "(open-binary-input-file filename) +(define (open-binary-input-file filename) + "(open-binary-input-file filename) - Function return new Input Binary Port with given filename. In Browser - user need to provide global fs variable that is instance of FS interface." - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "open-binary-input-file: fs not defined")) - (begin - (if (not (procedure? readFile)) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (filename) - (Uint8Array.from (_readFile filename)))))) - (new lips.InputBinaryFilePort (readFile filename) filename))))))) + Function return new Input Binary Port with given filename. In Browser + user need to provide global fs variable that is instance of FS interface." + (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) + (new lips.InputBinaryFilePort u8vector filename))) ;; ----------------------------------------------------------------------------- (define (binary-port? port) From 2a8cd6a626d1d5c74ab20075de0b4a8dbcee38cb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 10:52:05 +0100 Subject: [PATCH 068/109] fix exception on close of binary input port #132 --- README.md | 2 +- dist/lips.js | 200 ++++++++++++++++++++++++----------------------- dist/lips.min.js | 4 +- dist/std.min.scm | 12 ++- dist/std.scm | 12 +++ src/lips.js | 3 +- 6 files changed, 130 insertions(+), 103 deletions(-) diff --git a/README.md b/README.md index b0c2b282..5041f34e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&857111d6fac81d841a631629a0ed065c0b5f254a)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a5c8365ab6c9a1a4c4fa1b4f51cb4fdd7c91b85e)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&adef7a32efa92798c218d1517ddd0082)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 57b08093..e55d5818 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 02 Mar 2021 15:40:21 +0000 + * build: Wed, 03 Mar 2021 09:46:12 +0000 */ (function () { 'use strict'; @@ -3354,9 +3354,13 @@ function read_only(object, property, value) { - var hidden = arguments.length > 3 && arguments[3] !== undefined$1 ? arguments[3] : false; + var _ref10 = arguments.length > 3 && arguments[3] !== undefined$1 ? arguments[3] : {}, + _ref10$hidden = _ref10.hidden, + hidden = _ref10$hidden === void 0 ? false : _ref10$hidden; + Object.defineProperty(object, property, { value: value, + configurable: true, enumerable: !hidden }); } // ---------------------------------------------------------------------- @@ -4530,10 +4534,10 @@ var str_mapping = new Map(); - [[true, '#t'], [false, '#f'], [null, 'null'], [undefined$1, '#<undefined>']].forEach(function (_ref10) { - var _ref11 = slicedToArray(_ref10, 2), - key = _ref11[0], - value = _ref11[1]; + [[true, '#t'], [false, '#f'], [null, 'null'], [undefined$1, '#<undefined>']].forEach(function (_ref11) { + var _ref12 = slicedToArray(_ref11, 2), + key = _ref12[0], + value = _ref12[1]; str_mapping.set(key, value); }); // ---------------------------------------------------------------------- @@ -4630,10 +4634,10 @@ [[Error, function (e) { return e.message; - }], [Pair, function (pair, _ref12) { - var quote = _ref12.quote, - skip_cycles = _ref12.skip_cycles, - pair_args = _ref12.pair_args; + }], [Pair, function (pair, _ref13) { + var quote = _ref13.quote, + skip_cycles = _ref13.skip_cycles, + pair_args = _ref13.pair_args; // make sure that repr directly after update set the cycle ref if (!skip_cycles) { @@ -4641,16 +4645,16 @@ } return pair.toString.apply(pair, [quote].concat(toConsumableArray(pair_args))); - }], [LCharacter, function (chr, _ref13) { - var quote = _ref13.quote; + }], [LCharacter, function (chr, _ref14) { + var quote = _ref14.quote; if (quote) { return chr.toString(); } return chr.valueOf(); - }], [LString, function (str, _ref14) { - var quote = _ref14.quote; + }], [LString, function (str, _ref15) { + var quote = _ref15.quote; str = str.toString(); if (quote) { @@ -4660,10 +4664,10 @@ return str; }], [RegExp, function (re) { return '#' + re.toString(); - }]].forEach(function (_ref15) { - var _ref16 = slicedToArray(_ref15, 2), - cls = _ref16[0], - fn = _ref16[1]; + }]].forEach(function (_ref16) { + var _ref17 = slicedToArray(_ref16, 2), + cls = _ref17[0], + fn = _ref17[1]; instances.set(cls, fn); }); // ---------------------------------------------------------------------- @@ -4970,9 +4974,9 @@ Pair.prototype.toString = function (quote) { - var _ref17 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - _ref17$nested = _ref17.nested, - nested = _ref17$nested === void 0 ? false : _ref17$nested; + var _ref18 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + _ref18$nested = _ref18.nested, + nested = _ref18$nested === void 0 ? false : _ref18$nested; if (is_debug()) { var result = []; @@ -5232,10 +5236,10 @@ }; // ---------------------------------------------------------------------- - Macro.prototype.invoke = function (code, _ref18, macro_expand) { - var env = _ref18.env, - dynamic_scope = _ref18.dynamic_scope, - error = _ref18.error; + Macro.prototype.invoke = function (code, _ref19, macro_expand) { + var env = _ref19.env, + dynamic_scope = _ref19.dynamic_scope, + error = _ref19.error; var args = { dynamic_scope: dynamic_scope, error: error, @@ -5259,7 +5263,7 @@ function macro_expand(single) { return /*#__PURE__*/function () { - var _ref19 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(code, args) { + var _ref20 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee8(code, args) { var env, traverse, _traverse; return regenerator.wrap(function _callee8$(_context8) { @@ -5464,7 +5468,7 @@ })); return function (_x4, _x5) { - return _ref19.apply(this, arguments); + return _ref20.apply(this, arguments); }; }(); } // ---------------------------------------------------------------------- @@ -5483,9 +5487,9 @@ Syntax.prototype = Object.create(Macro.prototype); - Syntax.prototype.invoke = function (code, _ref20, macro_expand) { - var error = _ref20.error, - env = _ref20.env; + Syntax.prototype.invoke = function (code, _ref21, macro_expand) { + var error = _ref21.error, + env = _ref21.env; var args = { error: error, env: env, @@ -6102,8 +6106,8 @@ function traverse(expr) { - var _ref21 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - disabled = _ref21.disabled; + var _ref22 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + disabled = _ref22.disabled; log('traverse>> ' + expr.toString()); @@ -6736,9 +6740,9 @@ } }).then(exec); } else { - values.forEach(function (_ref22) { - var name = _ref22.name, - value = _ref22.value; + values.forEach(function (_ref23) { + var name = _ref23.name, + value = _ref23.value; env.set(name, value); }); } @@ -6782,9 +6786,9 @@ function pararel(name, fn) { return new Macro(name, function (code) { - var _ref23 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref23.dynamic_scope, - error = _ref23.error; + var _ref24 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref24.dynamic_scope, + error = _ref24.error; var env = this; @@ -8786,7 +8790,7 @@ InputPort.prototype._with_init_parser = function (make_parser, fn) { var self = this; return /*#__PURE__*/function () { - var _ref25 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { + var _ref26 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { var parser, _len15, args, @@ -8818,7 +8822,7 @@ })); return function () { - return _ref25.apply(this, arguments); + return _ref26.apply(this, arguments); }; }(); }; @@ -9159,11 +9163,11 @@ function Interpreter(name) { - var _ref26 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - stderr = _ref26.stderr, - stdin = _ref26.stdin, - stdout = _ref26.stdout, - obj = objectWithoutProperties(_ref26, ["stderr", "stdin", "stdout"]); + var _ref27 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + stderr = _ref27.stderr, + stdin = _ref27.stdin, + stdout = _ref27.stdout, + obj = objectWithoutProperties(_ref27, ["stderr", "stdin", "stdout"]); if (typeof this !== 'undefined' && !(this instanceof Interpreter) || typeof this === 'undefined') { return new Interpreter(name, _objectSpread({ @@ -9950,9 +9954,9 @@ return unbind(a) === unbind(b); }, "(%same-functions a b)\n\n Helper function that check if two bound functions are the same"), // ------------------------------------------------------------------ - help: doc(new Macro('help', function (code, _ref27) { - var dynamic_scope = _ref27.dynamic_scope, - error = _ref27.error; + help: doc(new Macro('help', function (code, _ref28) { + var dynamic_scope = _ref28.dynamic_scope, + error = _ref28.error; var symbol; if (code.car instanceof LSymbol) { @@ -10016,9 +10020,9 @@ 'set!': doc(new Macro('set!', function (code) { var _this15 = this; - var _ref28 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref28.dynamic_scope, - error = _ref28.error; + var _ref29 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref29.dynamic_scope, + error = _ref29.error; if (dynamic_scope) { dynamic_scope = this; @@ -10217,14 +10221,14 @@ }, "(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', /*#__PURE__*/function () { - var _ref29 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(code, _ref30) { + var _ref30 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee13(code, _ref31) { var dynamic_scope, error, self, scope, vars, test, body, eval_args, node, item, _loop3; return regenerator.wrap(function _callee13$(_context13) { while (1) { switch (_context13.prev = _context13.next) { case 0: - dynamic_scope = _ref30.dynamic_scope, error = _ref30.error; + dynamic_scope = _ref31.dynamic_scope, error = _ref31.error; self = this; if (dynamic_scope) { @@ -10371,13 +10375,13 @@ })); return function (_x10, _x11) { - return _ref29.apply(this, arguments); + return _ref30.apply(this, arguments); }; }()), "(do ((<var> <init> <next>)) (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 (code, _ref31) { - var dynamic_scope = _ref31.dynamic_scope, - error = _ref31.error; + 'if': doc(new Macro('if', function (code, _ref32) { + var dynamic_scope = _ref32.dynamic_scope, + error = _ref32.error; if (dynamic_scope) { dynamic_scope = this; @@ -10469,9 +10473,9 @@ }(); }), "(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 (code, _ref32) { - var dynamic_scope = _ref32.dynamic_scope, - error = _ref32.error; + 'ignore': new Macro('ignore', function (code, _ref33) { + var dynamic_scope = _ref33.dynamic_scope, + error = _ref33.error; var args = { env: this, error: error @@ -10615,9 +10619,9 @@ }, "(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."), // ------------------------------------------------------------------ lambda: new Macro('lambda', function (code) { - var _ref33 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref33.dynamic_scope, - error = _ref33.error; + var _ref34 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref34.dynamic_scope, + error = _ref34.error; var self = this; @@ -10731,9 +10735,9 @@ 'macroexpand': new Macro('macroexpand', macro_expand()), 'macroexpand-1': new Macro('macroexpand-1', macro_expand(true)), // ------------------------------------------------------------------ - 'define-macro': doc(new Macro(macro, function (macro, _ref34) { - var dynamic_scope = _ref34.dynamic_scope, - error = _ref34.error; + 'define-macro': doc(new Macro(macro, function (macro, _ref35) { + var dynamic_scope = _ref35.dynamic_scope, + error = _ref35.error; if (macro.car instanceof Pair && macro.car.car instanceof LSymbol) { var name = macro.car.car.__name__; @@ -10845,8 +10849,8 @@ validate_identifiers(macro.car); } - var syntax = new Syntax(function (code, _ref35) { - var macro_expand = _ref35.macro_expand; + var syntax = new Syntax(function (code, _ref36) { + var macro_expand = _ref36.macro_expand; var scope = env.inherit('syntax'); if (dynamic_scope) { @@ -10985,10 +10989,10 @@ } if (is_promise(car) || is_promise(cdr)) { - return Promise.all([car, cdr]).then(function (_ref36) { - var _ref37 = slicedToArray(_ref36, 2), - car = _ref37[0], - cdr = _ref37[1]; + return Promise.all([car, cdr]).then(function (_ref37) { + var _ref38 = slicedToArray(_ref37, 2), + car = _ref38[0], + cdr = _ref38[1]; return new Pair(car, cdr); }); @@ -11669,11 +11673,11 @@ return false; }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ - 'try': doc(new Macro('try', function (code, _ref38) { + 'try': doc(new Macro('try', function (code, _ref39) { var _this17 = this; - var dynamic_scope = _ref38.dynamic_scope, - _error = _ref38.error; + var dynamic_scope = _ref39.dynamic_scope, + _error = _ref39.error; return new Promise(function (resolve, reject) { var catch_clause, finally_clause; @@ -12156,9 +12160,9 @@ // ------------------------------------------------------------------ 'eq?': doc('eq?', equal, "(eq? a b)\n\n Function compare two values if they are identical."), // ------------------------------------------------------------------ - or: doc(new Macro('or', function (code, _ref39) { - var dynamic_scope = _ref39.dynamic_scope, - error = _ref39.error; + or: doc(new Macro('or', function (code, _ref40) { + var dynamic_scope = _ref40.dynamic_scope, + error = _ref40.error; var args = global_env.get('list->array')(code); var self = this; @@ -12201,9 +12205,9 @@ }), "(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 (code) { - var _ref40 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - dynamic_scope = _ref40.dynamic_scope, - error = _ref40.error; + var _ref41 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + dynamic_scope = _ref41.dynamic_scope, + error = _ref41.error; var args = global_env.get('list->array')(code); var self = this; @@ -12712,10 +12716,10 @@ } // ------------------------------------------------------------------------- - function evaluate_args(rest, _ref41) { - var env = _ref41.env, - dynamic_scope = _ref41.dynamic_scope, - error = _ref41.error; + function evaluate_args(rest, _ref42) { + var env = _ref42.env, + dynamic_scope = _ref42.dynamic_scope, + error = _ref42.error; var args = []; var node = rest; markCycles(node); @@ -12834,11 +12838,11 @@ function apply(fn, args) { - var _ref42 = arguments.length > 2 && arguments[2] !== undefined$1 ? arguments[2] : {}, - env = _ref42.env, - dynamic_scope = _ref42.dynamic_scope, - _ref42$error = _ref42.error, - error = _ref42$error === void 0 ? function () {} : _ref42$error; + var _ref43 = arguments.length > 2 && arguments[2] !== undefined$1 ? arguments[2] : {}, + env = _ref43.env, + dynamic_scope = _ref43.dynamic_scope, + _ref43$error = _ref43.error, + error = _ref43$error === void 0 ? function () {} : _ref43$error; args = evaluate_args(args, { env: env, @@ -12883,11 +12887,11 @@ function evaluate(code) { - var _ref43 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, - env = _ref43.env, - dynamic_scope = _ref43.dynamic_scope, - _ref43$error = _ref43.error, - error = _ref43$error === void 0 ? function () {} : _ref43$error; + var _ref44 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, + env = _ref44.env, + dynamic_scope = _ref44.dynamic_scope, + _ref44$error = _ref44.error, + error = _ref44$error === void 0 ? function () {} : _ref44$error; try { if (dynamic_scope === true) { @@ -13461,10 +13465,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Tue, 02 Mar 2021 15:40:21 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 03 Mar 2021 09:46:12 +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, 02 Mar 2021 15:40:21 +0000').valueOf(); + var date = LString('Wed, 03 Mar 2021 09:46:12 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13504,7 +13508,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Tue, 02 Mar 2021 15:40:21 +0000', + date: 'Wed, 03 Mar 2021 09:46:12 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 1419736f..93b0a246 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Tue, 02 Mar 2021 15:40:21 +0000 + * build: Wed, 03 Mar 2021 09:46:12 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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]:false;Object.defineProperty(e,r,{value:t,enumerable:!n})}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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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, 02 Mar 2021 15:40:21 +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,") <https://lips.js.org>\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, 02 Mar 2021 15:40:21 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 09:46:12 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 09:46:12 +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,InputBinaryFilePort:InputBinaryFilePort,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/dist/std.min.scm b/dist/std.min.scm index 39086bc8..f5e99831 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -678,7 +678,17 @@ whole vector is copied and returned." (if (null? rest) (new Uint8Array v) (let ( (bytevector-copy! to at from start end) Copies the bytes of bytevector from between start and end to bytevector to, -starting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1))))))(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end)))))))(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end)))))))(define (open-input-string string) "(open-input-string string) +starting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1))))))(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) "(string->utf8 string) +(string->utf8 string start) +(string->utf8 string start end) + +Function converts string into u8 bytevector using utf8 encoding. +The start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end)))))))(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector) +(utf8->string u8vector start) +(utf8->string u8vector start end) + +Function converts u8 bytevector into string using utf8 encoding. +The start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end)))))))(define (open-input-string string) "(open-input-string string) Function create new string port as input that can be used to read S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment)))(define (open-output-string) "(open-output-string) diff --git a/dist/std.scm b/dist/std.scm index 0caea33f..0b178a9c 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3438,6 +3438,12 @@ (define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) + "(string->utf8 string) + (string->utf8 string start) + (string->utf8 string start end) + + Function converts string into u8 bytevector using utf8 encoding. + The start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) @@ -3449,6 +3455,12 @@ (define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) + "(utf8->string u8vector) + (utf8->string u8vector start) + (utf8->string u8vector start end) + + Function converts u8 bytevector into string using utf8 encoding. + The start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) diff --git a/src/lips.js b/src/lips.js index 559477c9..9e032b25 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1530,9 +1530,10 @@ } return fn(value); }// ---------------------------------------------------------------------- - function read_only(object, property, value, hidden = false) { + function read_only(object, property, value, { hidden = false } = {}) { Object.defineProperty(object, property, { value, + configurable: true, enumerable: !hidden }); } From 7541ddb446f2245adbcfac44d03fadfa56616e29 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 11:02:55 +0100 Subject: [PATCH 069/109] add new gensym-interal syntax --- CHANGELOG.md | 1 + dist/std.min.scm | 4 +++- dist/std.scm | 12 +++++++++++- lib/bootstrap.scm | 12 +++++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6828aa3d..0ecaa1bb 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ * properly handle negative inexact zero * new `environment?` function * add `current-directory` and `set-...` from SRFI-170 +* add gensym literals (e.g. `#:foo`) ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/dist/std.min.scm b/dist/std.min.scm index f5e99831..c04c605e 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -47,7 +47,9 @@ Function check if argument is list with single element" (and (pair? list) (not ( Function check if value is JavaScript iterator object" (and (object? x) (procedure? (. x Symbol.iterator))))(define-macro (.. expr) "(.. foo.bar.baz) -Macro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts))))))))(define (plain-object? x) "(plain-object? x) +Macro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts))))))))(set-special! "#:" (quote gensym-interal) lips.specials.LITERAL)(define (gensym-interal symbol) "(gensym-interal symbol) + +Parser extension that create new quoted named gensym." (quasiquote (quote (unquote (gensym symbol)))))(define (plain-object? x) "(plain-object? x) Function check if value is plain JavaScript object. Created using object macro." (and (== (--> (type x) (cmp "object")) 0) (eq? (. x (quote constructor)) Object)))(define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o) diff --git a/dist/std.scm b/dist/std.scm index 0b178a9c..7fffee52 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -170,6 +170,16 @@ expr `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) +;; ----------------------------------------------------------------------------- +(set-special! "#:" 'gensym-interal lips.specials.LITERAL) + +;; ----------------------------------------------------------------------------- +(define (gensym-interal symbol) + "(gensym-interal symbol) + + Parser extension that create new quoted named gensym." + `(quote ,(gensym symbol))) + ;; ----------------------------------------------------------------------------- (define (plain-object? x) "(plain-object? x) @@ -351,7 +361,7 @@ ;; ----------------------------------------------------------------------------- (define (%hidden-props obj) "(%hidden-props obj) - + Function return hidden names of an object, for ES6 class prototype it return all methods since they are indistinguishable from hidden property created using defineProperty." diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 3d53ed42..66c0ccff 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -170,6 +170,16 @@ expr `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) +;; ----------------------------------------------------------------------------- +(set-special! "#:" 'gensym-interal lips.specials.LITERAL) + +;; ----------------------------------------------------------------------------- +(define (gensym-interal symbol) + "(gensym-interal symbol) + + Parser extension that create new quoted named gensym." + `(quote ,(gensym symbol))) + ;; ----------------------------------------------------------------------------- (define (plain-object? x) "(plain-object? x) @@ -351,7 +361,7 @@ ;; ----------------------------------------------------------------------------- (define (%hidden-props obj) "(%hidden-props obj) - + Function return hidden names of an object, for ES6 class prototype it return all methods since they are indistinguishable from hidden property created using defineProperty." From 5aa1b5a2fbb7fa933714cb20a34cf110d63e939b Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 13:47:22 +0100 Subject: [PATCH 070/109] fix pretty print of different cases of `let` --- README.md | 4 +- dist/lips.js | 72 ++-- dist/lips.min.js | 4 +- src/lips.js | 33 +- tests/formatter.scm | 23 +- tests/snapshots/test.js.md | 642 ++--------------------------------- tests/snapshots/test.js.snap | Bin 18407 -> 18164 bytes 7 files changed, 104 insertions(+), 674 deletions(-) diff --git a/README.md b/README.md index 5041f34e..c5b4e2b2 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&a5c8365ab6c9a1a4c4fa1b4f51cb4fdd7c91b85e)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&adef7a32efa92798c218d1517ddd0082)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&102de4ade46b09bbed7c4c1010ebac7ad1e01433)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&086bf7f3991d67123193784c9453ae9a)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index e55d5818..0fc16260 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 09:46:12 +0000 + * build: Wed, 03 Mar 2021 12:42:34 +0000 */ (function () { 'use strict'; @@ -1887,7 +1887,7 @@ function is_symbol_string(str) { - return !(['(', ')'].includes(str) || str.match(re_re) || str.match(/^"[\s\S]*"$/) || str.match(int_re) || str.match(float_re) || str.match(complex_re) || str.match(rational_re) || str.match(char_re) || ['#t', '#f', 'nil', 'true', 'false'].includes(str)); + return !(['(', ')', '[', ']'].includes(str) || str.match(re_re) || str.match(/^"[\s\S]*"$/) || str.match(int_re) || str.match(float_re) || str.match(complex_re) || str.match(rational_re) || str.match(char_re) || ['#t', '#f', 'nil', 'true', 'false'].includes(str)); } // ---------------------------------------------------------------------- @@ -3576,38 +3576,12 @@ return 0; } // ---------------------------------------------------------------------- - // :: token based pattern matching (used by formatter) - // ---------------------------------------------------------------------- - - - function nested_pattern(pattern) { - return pattern instanceof Array || pattern instanceof Pattern; - } // ---------------------------------------------------------------------- function match(pattern, input) { return inner_match(pattern, input) === input.length; function inner_match(pattern, input) { - function empty_match() { - if (p <= 0 && i <= 0) { - return false; - } - - var prev_pattern = pattern[p - 1]; - - if (!nested_pattern(prev_pattern)) { - prev_pattern = [prev_pattern]; - } - - var next_pattern = pattern[p + 1]; - - if (next_pattern && !nested_pattern(next_pattern)) { - next_pattern = [next_pattern]; - } - - return match(prev_pattern, [input[i - 1]]) && (!next_pattern || match(next_pattern, [input[i]])); - } function not_symbol_match() { return pattern[p] === Symbol["for"]('symbol') && !is_symbol_string(input[i]); @@ -3626,6 +3600,11 @@ var glob = {}; for (var i = 0; i < input.length; ++i) { + log({ + input: input[i], + pattern: pattern[p] + }); + if (typeof pattern[p] === 'undefined') { return i; } @@ -3669,18 +3648,15 @@ } else if (_typeof_1(pattern[p]) === 'symbol') { if (pattern[p] === Symbol["for"]('*')) { // ignore S-expressions inside for case when next pattern is ) - glob[p] = glob[p] || 0; - var zero_match = empty_match(); + glob[p] = glob[p] || 0; //var zero_match = empty_match(); if (['(', '['].includes(input[i])) { glob[p]++; - } else if ([')', ']'].includes(input[i]) && !zero_match) { + } else if ([')', ']'].includes(input[i])) { glob[p]--; } - if (zero_match) { - i -= 1; - } else if (typeof pattern[p + 1] !== 'undefined' && glob[p] === 0 && match_next() === -1 || glob[p] > 0) { + if (typeof pattern[p + 1] !== 'undefined' && glob[p] === 0 && match_next() === -1 || glob[p] > 0) { continue; } } else if (not_symbol_match()) { @@ -3931,7 +3907,6 @@ var p_e = /[\])]/; var not_p = /[^()[\]]/; var not_close = new Ahead(/[^)\]]/); - var open = new Ahead(/[([]/); var glob = Symbol["for"]('*'); var sexp = new Pattern([p_o, glob, p_e], '+'); var symbol = new Pattern([Symbol["for"]('symbol')], '?'); @@ -3956,7 +3931,9 @@ } // line breaking rules - Formatter.rules = [[[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], [[p_o, let_re, p_o, let_value, p_e, sexp], 1, not_close], [[p_o, keywords_re('define-syntax'), /.+/], 1], [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, open], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], [[p_o, def_lambda_re, identifiers], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re, sexp], 1, not_close], [[p_o, def_lambda_re, identifiers, sexp], 1, not_close]]; // ---------------------------------------------------------------------- + Formatter.rules = [[[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], //[[p_o, let_re, p_o, let_value], 1, not_close], + //s[[p_o, let_re, p_o, let_value, p_e, sexp], 0, not_close], + [[p_o, keywords_re('define-syntax'), /.+/], 1], [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, not_close], [[p_o, let_re, sexp], 1, not_close], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], [[p_o, def_lambda_re, identifiers], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re, sexp], 1, not_close], [[p_o, def_lambda_re, identifiers, sexp], 1, not_close]]; // ---------------------------------------------------------------------- Formatter.prototype["break"] = function () { var code = this.__code__.replace(/\n[ \t]*/g, '\n '); @@ -3980,13 +3957,16 @@ } var sub = tokens.slice(0, i); + + if (sub.join('') === '(let ((xxx (if (null? rest) (current-input-port) (car rest))) ') ; + var sexp = {}; rules.map(function (b) { return b[1]; }).forEach(function (count) { count = count.valueOf(); - if (!sexp[count]) { + if (count > 0 && !sexp[count]) { sexp[count] = previousSexp(sub, count); } }); @@ -4002,7 +3982,8 @@ ext = _step6$value[2]; count = count.valueOf(); - var m = match(pattern, sexp[count].filter(function (t) { + var test_sexp = count > 0 ? sexp[count] : sub; + var m = match(pattern, test_sexp.filter(function (t) { return t.trim(); })); var next = tokens.slice(i).find(function (t) { @@ -4010,8 +3991,13 @@ }); if (m && (ext instanceof Ahead && ext.match(next) || !ext)) { - tokens.splice(i, 0, '\n'); - i++; + if (!tokens[i - 1].trim()) { + tokens[i - 1] = '\n'; + } else { + tokens.splice(i, 0, '\n'); + i++; + } + continue; } } @@ -13465,10 +13451,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 03 Mar 2021 09:46:12 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 03 Mar 2021 12:42:34 +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('Wed, 03 Mar 2021 09:46:12 +0000').valueOf(); + var date = LString('Wed, 03 Mar 2021 12:42:34 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13508,7 +13494,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 03 Mar 2021 09:46:12 +0000', + date: 'Wed, 03 Mar 2021 12:42:34 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 93b0a246..3975673b 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 09:46:12 +0000 + * build: Wed, 03 Mar 2021 12:42:34 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 nested_pattern(e){return e instanceof Array||e instanceof Pattern}function match(e,r){return f(e,r)===r.length;function f(t,n){function e(){if(a<=0&&o<=0){return false}var e=t[a-1];if(!nested_pattern(e)){e=[e]}var r=t[a+1];if(r&&!nested_pattern(r)){r=[r]}return match(e,[n[o-1]])&&(!r||match(r,[n[o]]))}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 f([e],[r])}}var a=0;var u={};for(var o=0;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=f(t[a].pattern,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=f(t[a].pattern,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;var s=e();if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])&&!s){u[a]--}if(s){o-=1}else if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){continue}}else if(r()){return-1}}else if(t[a]instanceof Array){var l=f(t[a],n.slice(o));if(l===-1||l+o>n.length){return-1}o+=l-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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};Formatter.Pattern=Pattern;Formatter.Ahead=Ahead;var p_o=/[[(]/;var p_e=/[\])]/;var not_p=/[^()[\]]/;var not_close=new Ahead(/[^)\]]/);var open=new Ahead(/[([]/);var glob=Symbol["for"]("*");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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,p_o,let_value,p_e,sexp],1,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,open],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(!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=match(l,u[f].filter(function(e){return e.trim()}));var h=t.slice(i).find(function(e){return e.trim()});if(p&&(_ instanceof Ahead&&_.match(h)||!_)){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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 09:46:12 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 09:46:12 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){log({input:n[u],pattern:t[i]});if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);if(a.join("")==="(let ((xxx (if (null? rest) (current-input-port) (car rest))) ");var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 12:42:34 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 12:42:34 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index 9e032b25..95bc6410 100644 --- a/src/lips.js +++ b/src/lips.js @@ -569,7 +569,7 @@ } // ---------------------------------------------------------------------- function is_symbol_string(str) { - return !(['(', ')'].includes(str) || str.match(re_re) || + return !(['(', ')', '[', ']'].includes(str) || str.match(re_re) || str.match(/^"[\s\S]*"$/) || str.match(int_re) || str.match(float_re) || str.match(complex_re) || str.match(rational_re) || str.match(char_re) || @@ -1677,6 +1677,7 @@ var p = 0; var glob = {}; for (var i = 0; i < input.length; ++i) { + log({input: input[i], pattern: pattern[p]}); if (typeof pattern[p] === 'undefined') { return i; } @@ -1714,15 +1715,13 @@ if (pattern[p] === Symbol.for('*')) { // ignore S-expressions inside for case when next pattern is ) glob[p] = glob[p] || 0; - var zero_match = empty_match(); + //var zero_match = empty_match(); if (['(', '['].includes(input[i])) { glob[p]++; - } else if ([')', ']'].includes(input[i]) && !zero_match) { + } else if ([')', ']'].includes(input[i])) { glob[p]--; } - if (zero_match) { - i -= 1; - } else if ((typeof pattern[p + 1] !== 'undefined' && + if ((typeof pattern[p + 1] !== 'undefined' && glob[p] === 0 && match_next() === -1) || glob[p] > 0) { continue; @@ -1941,10 +1940,12 @@ Formatter.rules = [ [[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], - [[p_o, let_re, p_o, let_value, p_e, sexp], 1, not_close], + //[[p_o, let_re, p_o, let_value], 1, not_close], + //s[[p_o, let_re, p_o, let_value, p_e, sexp], 0, not_close], [[p_o, keywords_re('define-syntax'), /.+/], 1], [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], - [[p_o, sexp], 1, open], + [[p_o, sexp], 1, not_close], + [[p_o, let_re, sexp], 1, not_close], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], @@ -1970,20 +1971,28 @@ continue; } var sub = tokens.slice(0, i); + if (sub.join('') === '(let ((xxx (if (null? rest) (current-input-port) (car rest))) ') { + //debugger; + } var sexp = {}; rules.map(b => b[1]).forEach(count => { count = count.valueOf(); - if (!sexp[count]) { + if (count > 0 && !sexp[count]) { sexp[count] = previousSexp(sub, count); } }); for (let [pattern, count, ext] of rules) { count = count.valueOf(); - var m = match(pattern, sexp[count].filter(t => t.trim())); + var test_sexp = count > 0 ? sexp[count] : sub; + var m = match(pattern, test_sexp.filter(t => t.trim())); var next = tokens.slice(i).find(t => t.trim()); if (m && (ext instanceof Ahead && ext.match(next) || !ext)) { - tokens.splice(i, 0, '\n'); - i++; + if (!tokens[i - 1].trim()) { + tokens[i - 1] = '\n'; + } else { + tokens.splice(i, 0, '\n'); + i++; + } continue; } } diff --git a/tests/formatter.scm b/tests/formatter.scm index 7303a1bc..07a43b79 100644 --- a/tests/formatter.scm +++ b/tests/formatter.scm @@ -10,13 +10,13 @@ (display "not zero") (newline)))))))) + (test "formatter: named let" (lambda (t) (t.snapshot (pretty-format '(let iter ((x 10)) (if (not (zero? x)) (iter (- x 1)))))))) - (test "formatter: let" (lambda (t) (t.snapshot (pretty-format '(let ((x 10)) @@ -25,7 +25,26 @@ (t.snapshot (pretty-format '(let ((x)) (print x) - (print x)))))) + (print x)))) + + (t.snapshot (pretty-format '(let ((bar (foo bar (baz))) + (foo 10)) + (foo bar) + (print0)))) + + (t.snapshot (pretty-format '(let ((bar) + (foo (baz quux)) + (foo 10)) + (foo bar) + (print0)))) + + (t.snapshot (pretty-format '(let ((foo 10) + (xxx (if (null? rest) + (current-input-port) + (car rest))) + (bar foo)) + (foo bar) + (print0)))))) (test "formatter: cond" (lambda (t) diff --git a/tests/snapshots/test.js.md b/tests/snapshots/test.js.md index cbbb7a74..0e39e1d3 100644 --- a/tests/snapshots/test.js.md +++ b/tests/snapshots/test.js.md @@ -8,7 +8,8 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - `(cond ((foo 10) 10)␊ + `(cond ((foo 10)␊ + 10)␊ ((foo (bar baz))␊ (begin␊ (display "x")␊ @@ -18,7 +19,8 @@ Generated by [AVA](https://avajs.dev). > Snapshot 2 - `(cond ((foo 10) 10)␊ + `(cond ((foo 10)␊ + 10)␊ ((foo)␊ (begin␊ (display "x")␊ @@ -80,6 +82,31 @@ Generated by [AVA](https://avajs.dev). (print x)␊ (print x))` +> Snapshot 3 + + `(let ((bar (foo bar (baz)))␊ + (foo 10))␊ + (foo bar)␊ + (print0))` + +> Snapshot 4 + + `(let ((bar)␊ + (foo (baz quux))␊ + (foo 10))␊ + (foo bar)␊ + (print0))` + +> Snapshot 5 + + `(let ((foo 10)␊ + (xxx (if (null? rest)␊ + (current-input-port)␊ + (car rest)))␊ + (bar foo))␊ + (foo bar)␊ + (print0))` + ## formatter: let+if+begin > Snapshot 1 @@ -149,617 +176,6 @@ Generated by [AVA](https://avajs.dev). '<div data-foo="hello" id="foo"><button id="btn1">me</button><button id="btn2">me</button></div>' -## parser: tokenizer - -> Snapshot 1 - - [ - { - col: 0, - line: 0, - offset: 0, - token: '(', - }, - { - col: 1, - line: 0, - offset: 1, - token: 'define-macro', - }, - { - col: 13, - line: 0, - offset: 13, - token: ' ', - }, - { - col: 14, - line: 0, - offset: 14, - token: '(', - }, - { - col: 15, - line: 0, - offset: 15, - token: 'defstruct', - }, - { - col: 24, - line: 0, - offset: 24, - token: ' ', - }, - { - col: 25, - line: 0, - offset: 25, - token: 'name', - }, - { - col: 29, - line: 0, - offset: 29, - token: ' ', - }, - { - col: 30, - line: 0, - offset: 30, - token: '.', - }, - { - col: 31, - line: 0, - offset: 31, - token: ' ', - }, - { - col: 32, - line: 0, - offset: 32, - token: 'fields', - }, - { - col: 38, - line: 0, - offset: 38, - token: ')', - }, - { - col: 39, - line: 0, - offset: 39, - token: `␊ - `, - }, - { - col: 0, - line: 1, - offset: 40, - token: ' ', - }, - { - col: 2, - line: 1, - offset: 42, - token: '"First Line."', - }, - { - col: 15, - line: 1, - offset: 55, - token: ' ', - }, - { - col: 16, - line: 1, - offset: 56, - token: '"word"', - }, - { - col: 22, - line: 1, - offset: 62, - token: ' ', - }, - { - col: 23, - line: 1, - offset: 63, - token: '10', - }, - { - col: 25, - line: 1, - offset: 65, - token: `␊ - `, - }, - { - col: 0, - line: 2, - offset: 66, - token: ' ', - }, - { - col: 2, - line: 2, - offset: 68, - token: '"Second Line."', - }, - { - col: 16, - line: 2, - offset: 82, - token: ' ', - }, - { - col: 20, - line: 2, - offset: 86, - token: '"word"', - }, - { - col: 26, - line: 2, - offset: 92, - token: ' ', - }, - { - col: 27, - line: 2, - offset: 93, - token: '#/regex/', - }, - { - col: 35, - line: 2, - offset: 101, - token: `␊ - `, - }, - { - col: 0, - line: 3, - offset: 102, - token: ' ', - }, - { - col: 2, - line: 3, - offset: 104, - token: '"Third Line."', - }, - { - col: 15, - line: 3, - offset: 117, - token: ' ', - }, - { - col: 20, - line: 3, - offset: 122, - token: '"word"', - }, - { - col: 26, - line: 3, - offset: 128, - token: `␊ - `, - }, - { - col: 0, - line: 4, - offset: 129, - token: ' ', - }, - { - col: 2, - line: 4, - offset: 131, - token: '10', - }, - { - col: 4, - line: 4, - offset: 133, - token: ' ', - }, - { - col: 5, - line: 4, - offset: 134, - token: '10+10i', - }, - { - col: 11, - line: 4, - offset: 140, - token: ' ', - }, - { - col: 12, - line: 4, - offset: 141, - token: '+inf.0', - }, - { - col: 18, - line: 4, - offset: 147, - token: ' ', - }, - { - col: 19, - line: 4, - offset: 148, - token: '+inf.0+inf.0i', - }, - { - col: 32, - line: 4, - offset: 161, - token: ' ', - }, - { - col: 33, - line: 4, - offset: 162, - token: '+nan.0', - }, - { - col: 39, - line: 4, - offset: 168, - token: ' ', - }, - { - col: 40, - line: 4, - offset: 169, - token: '+nan.0+nan.0i', - }, - { - col: 53, - line: 4, - offset: 182, - token: `␊ - `, - }, - { - col: 0, - line: 5, - offset: 183, - token: ' ', - }, - { - col: 2, - line: 5, - offset: 185, - token: '1/2+1/2i', - }, - { - col: 10, - line: 5, - offset: 193, - token: ' ', - }, - { - col: 11, - line: 5, - offset: 194, - token: '10.10+1/2i', - }, - { - col: 21, - line: 5, - offset: 204, - token: ' ', - }, - { - col: 22, - line: 5, - offset: 205, - token: '1/2+10.0i', - }, - { - col: 31, - line: 5, - offset: 214, - token: `␊ - `, - }, - { - col: 0, - line: 6, - offset: 215, - token: ' ', - }, - { - col: 2, - line: 6, - offset: 217, - token: '(', - }, - { - col: 3, - line: 6, - offset: 218, - token: 'let', - }, - { - col: 6, - line: 6, - offset: 221, - token: ' ', - }, - { - col: 7, - line: 6, - offset: 222, - token: '(', - }, - { - col: 8, - line: 6, - offset: 223, - token: '(', - }, - { - col: 9, - line: 6, - offset: 224, - token: 'names', - }, - { - col: 14, - line: 6, - offset: 229, - token: ' ', - }, - { - col: 15, - line: 6, - offset: 230, - token: '(', - }, - { - col: 16, - line: 6, - offset: 231, - token: 'map', - }, - { - col: 19, - line: 6, - offset: 234, - token: ' ', - }, - { - col: 20, - line: 6, - offset: 235, - token: '(', - }, - { - col: 21, - line: 6, - offset: 236, - token: 'lambda', - }, - { - col: 27, - line: 6, - offset: 242, - token: ' ', - }, - { - col: 28, - line: 6, - offset: 243, - token: '(', - }, - { - col: 29, - line: 6, - offset: 244, - token: 'symbol', - }, - { - col: 35, - line: 6, - offset: 250, - token: ')', - }, - { - col: 36, - line: 6, - offset: 251, - token: ' ', - }, - { - col: 37, - line: 6, - offset: 252, - token: '(', - }, - { - col: 38, - line: 6, - offset: 253, - token: 'gensym', - }, - { - col: 44, - line: 6, - offset: 259, - token: ')', - }, - { - col: 45, - line: 6, - offset: 260, - token: ')', - }, - { - col: 46, - line: 6, - offset: 261, - token: ' ', - }, - { - col: 47, - line: 6, - offset: 262, - token: 'fields', - }, - { - col: 53, - line: 6, - offset: 268, - token: ')', - }, - { - col: 54, - line: 6, - offset: 269, - token: ')', - }, - { - col: 55, - line: 6, - offset: 270, - token: `␊ - `, - }, - { - col: 0, - line: 7, - offset: 271, - token: ' ', - }, - { - col: 8, - line: 7, - offset: 279, - token: '(', - }, - { - col: 9, - line: 7, - offset: 280, - token: 'struct', - }, - { - col: 15, - line: 7, - offset: 286, - token: ' ', - }, - { - col: 16, - line: 7, - offset: 287, - token: '(', - }, - { - col: 17, - line: 7, - offset: 288, - token: 'gensym', - }, - { - col: 23, - line: 7, - offset: 294, - token: ')', - }, - { - col: 24, - line: 7, - offset: 295, - token: ')', - }, - { - col: 25, - line: 7, - offset: 296, - token: `␊ - `, - }, - { - col: 0, - line: 8, - offset: 297, - token: ' ', - }, - { - col: 8, - line: 8, - offset: 305, - token: '(', - }, - { - col: 9, - line: 8, - offset: 306, - token: 'field-arg', - }, - { - col: 18, - line: 8, - offset: 315, - token: ' ', - }, - { - col: 19, - line: 8, - offset: 316, - token: '(', - }, - { - col: 20, - line: 8, - offset: 317, - token: 'gensym', - }, - { - col: 26, - line: 8, - offset: 323, - token: ')', - }, - { - col: 27, - line: 8, - offset: 324, - token: ')', - }, - { - col: 28, - line: 8, - offset: 325, - token: ')', - }, - { - col: 29, - line: 8, - offset: 326, - token: `␊ - `, - }, - { - col: 0, - line: 9, - offset: 327, - token: `␊ - `, - }, - ] - ## tokenizer: with meta data > Snapshot 1 diff --git a/tests/snapshots/test.js.snap b/tests/snapshots/test.js.snap index efa089f0b6743bbf44524505e4ac24df9b233280..fe03416e1f9e21c8564c2539d3304e72cde32743 100644 GIT binary patch delta 18083 zcmV)KK)S!@j{)?J0e?YOK_F9ZVQ_P3Z*(AbG716!{2puKn@u%#ZS)SXDPvrYABzY8 z0000000Zrv3AATLb?*P&O*b<Qg2*IXnyK5S;hd^ERp$T=$~>qDD2kxiBerR}v1zo` z7Zo$835vt>8S_^1)R<@z%`(q9M0sW~nivwI!I#A0CD9nCIDaM@jW6%}edi+dIr_it zy&-G8wP@T}eebDLb*gsl;oEx`w=J4X_MdD&`UUU)>ZdOI@b_N!wI{r|`@kXkq5ix{ zboRC*F8<{|UcCI!{r~b~&v^OUj$Y)SeqFS6@%9&fa=%}VM{jx0#^2a@{qm*$=}C)v zx_Xx0JWKyROMh=zJehp^`V)TP(KlT8H*fvu2jUfPxaYl#{nNEediqn*UNe`y;vp|T zs(Rje|MvB3FaC>5m-(lQ_v&fwEIoIY{$!TEF-w}tWcgqI->bR{pStt$liTmSXZ0)g zUgDpgKT9v2rLT#e);;6n|NSrjb<v0KS`xPIee~}x@_$dySvHxx<X1obre}TfL+89= zZFl<z4|v?)FY-^HE;{t?li&Q!yEZ-d+24KZ&P)I9sFyDGPoF(YU)?d8yz$5v-f-5* ztB>D&^J#Zn__4D-zsNtm?&itl6L+3<`Q7)ta@XPuPQCb(mtXp-MgHky-#?iwne6R# zU$k^`$baJ3Ojd5)v~y<V%3U*cwQALVGczl<Y@S*9+)X>SpEI+Izw>A1`b{@%**5zZ z{dMD(n{V2>?m06ncy7h2`+l)))3dj3*|urboE^7q-#POmJFi-G|2Zx?$5Y(0bJLE| zJbBFzCi{ay`$yNz=-JWBP9A;lO*^)1+u48X4}aRb_c`I-K6~2Xyx9)x*J&P`w{M?u zWBt14uDWlM{P^A}%sz788>_(!FTL-DyS;#S&OGy$TXxOwy^CLc@Al93y7wi!cI}#7 z;9ItCJ!fXerki)(w^8@**M?hm?AWwz=bA0sZn|aXnwz%o_+iiJ!`=ISETJE1xILWV z%YP;-H*DXwaWuvI&-UJ>*fHZJzW0d%^WBg8cHNKd#!TD4@P3SW?<5DjwD{INoZI|o z^dnw#--LGKl2cZ0+_YK!W_e@RU^`Z>)`{3P?6hWjrxjv_6+fcu>GyVZ&#mijT)%PM z_zgdz^LcyL+2ilg3y<9Wg<EdkIaAMsnSVHVZ2A2k(?$(e@aE@i+qrJnnjN=n-E{NJ zO7rE)>t`il|I*RG<%f6byKLFKYL8xW&EO?#*PeZEzjZVE%gp-O-h+i&xef+AOAE5@ z{!6#=Z2e^Ys*(76)a=)<=|^J`7-jqc_n-3pC%yaYj$XO4U*r8|hK>6k+)FCw`hT+9 z$=R~CsoPYyb(O2sR&B{$?Aoen>#lSqg;GN9+9o%3T~$r2yO{NODOD~Z=DKcD(={n{ zspywESGjIW)8w3DlTyhcmo~MbZc5N^Ls8E*rjV*ob+!H-8@(XMT$QHFIoF|U>Pjz* zRcyMLnyS@!RqCSJq0<CPTNTZz)qguu2r)%H-R9gjRSJ4ZYD%ti=rm~VO6;l}tI$?; zrI$4NLWb8H^y*q)6=UIlK_66Uj=9xutCFjxPWs@sYjf&ylS=9|VAM-AKaG^NNNt<+ zli0;p)2f<=X*QMS9CH_9&}%DwwEk#~v_M+m*y-<Grxoq=NE=e=v@oSg`hSond!|_n zsfB2~jtw7Km)Mpr#n7=Hu}itF+n{&rn@dcsW~@iEK3wnD=GFSlQc~M#ePSK7j{Hhn zq8%&RvQRXFzDr9~SK7TsOVL$)M^jo&IA$$sXzHv5*V|gHg&0HJ(P=)lmN_(H1}#$^ zw4P1Y46^t@3)QAlbzQA_>wn*Es;X31k(J2WZ|{WmUW=?P6-%j6YchJDR=KKz7DW3m z7SY0KB3g2dSVt{Q*7U_Vkq_7YYjJArP!uQTR)e>77Q1wzPEno3q*~m@Z_3P2OBkEz z*CjD*C-yDk&n{HjH1@U%K|Ci$t=hH{la*RqBu?Q|HQAb-&9z>vR(}(;u-ZcLdRr2+ z(94s)xMu4$zeeAyWzaVk?LaH$3H;$Riu$Jr^XX*iFllGo7$ZyHX^)t;Uad*AIwR`S z>X_(AX;JiIwj4H#LC1zo7PG5MVllMInxNRfXbZJijXs%;h<ZaU(n9D%gI*UK?YPF$ z$7*to{?~}Pv~o#HrhmhqT3(hoiJECk-%h{N52{-4OIib1MpG7Rb=oq?3oTuxy^BE$ zB5{zizCn9Z_z0blTH7fm);M~QiHVzXN)60hVlC#=P$d>^RTbgM5_D`dk6dcKwCIfK zn>aFEr)_L<(2|IIG<orv9?^Dc=c1Ywd<cUDZIgIVizP<ak$-3+o2~Plv_?8)U8PO$ z_}(mD)46Z8SNf^mDNfYK>PupU{Ly(xS)bc@%c53Zj22-@$u*sl0++!#dZNu*OYyUI zA?dhjacfvo{L&WjRnVM}LlQ$pv#Ud-rG>Nv5!;EQ`tFjt+CMfddz~AOxn7|;Yccha zEiyz~q|>BdAb&K()d7x>n9>Q+yd<2W&R?w`NVHanX)#T<e3D=cb>}tFu1fl7YsIt@ z_d14RfTm;l#k&&0m0qt+&^PGwqt8gtvDLP>nsO_FTWUm`q?u+UF|KE{R(hA%t_>2f zk|bI{Evj}>yr#Jq{jQVbY{bN#V${pEgl!8qs;@+E>wg1VN!+Qg#<OhdIBgZDn3L9M z&m<sNR~-!Tiw+oKq*QIkH?!iI18aSvxk=_VOe~<sU_o(*G?b*2SWxmVAj!K76YDIC zhqcpMA5AIhC!KVfIIu=m#RQ*8{GhR{8^ukUnm83M&~7k42?4!RN=_W8!=i^PO<aRY z`-r&<N`FY&F-fX)7CEhSTb4S|0jYwHrWjpY)`){bl8DeRBV9FHt%$x<Bl4pP1)wLh zg<H~^Y0jLbq~2N$&8gN`O84mtH3xkhTQBY@oILG48bF*PjiJ@ctSjn^1?c<}v`G<X zR0W|Td8^rq7XzmtA(0|4WEI$UF`m|`psUQx;(wI_dnW{|ED9YS{XpM=hVcPwdiky; zt*{WJL&Ra?c5yhWm>JecOhyzZHOxe-+=PHcMF8tjO|*gqwH@$^RG{`V1|M}TVBic! zMys$Nq|(rOC?LsrNdXC32^p<IM*n&XB^NLfbaeEvM1^Emp@;OYMr88ZP_2Q!L;^xO zEq|jQrK}RVMGI4;L4uZC?@I_WF`K?j$3pK+=xptgBnlcHrB|_mnv-`~I$S?am=(NG zoGaGQCTPJW7bSx=hQyveMu%HErNNZaQtMn)HTHyFs2!B#?R?D9MH-r;RLn$D=~_6g zkc1LKQ&O{G=Q>V?^jVGQ6kA9PRh${tB!8jC6GlT|$+13aj*J9`I8TxrO%;(&nvix= z{~*6PP1+kyd^YEzBgG~<PkOyLO;Qk3rpAPkc+p<9`i!XKtF0FUO0H;G^({e*EcU1* zwKc&yHHc6#mwK`q7KSZs(`fPag*v$s`c*3v7WLHho2Ko=xJ7DXlhxP}MXI!gqkj=l z2rO-8jai7UNm7f_yAi#`FJwP8@Ff}|V^WC^8+cg4O50c@M0E_X3Z(nRBYJnJkg<&> zD3b%zO`5uf*J~C-UsKy|68lHwr`SwpBU_i~8sK6KTn-Df5-(~C3IaF9gkg>#7jFdC zNY7(Ji5cKwY)Y&>ZLru|nqTTv0)I?X7Izl-H?yv2BymH_5z}0B&Scfu7mzkgh;DtS zz6|9h)<wSQSxGnSmxLmQIbk0e;bH}Stqxp3X>!04GqWzNa0j#qoG$Eki3Q1DNk8!b zcD~j?d<wT)oZxEkxv)GuscCENOD`m4QZyWh$Z;yT1eo|@C(M2LUREU1xPKNq=%+GZ zFdu_W4GBjXu#$w@6lSY$(x%9WvYLsQx;k7)f60Z6HpI$6O^EBn&^8<-eAQncB0Zul zwuz=$OB|`KA0g;Fbwc9jUQ=s%kQS2gT06vy7+8ji3_z_6QbgM+vtImHSlEQ^q-ivC z*7!jS$L`ncrq)P{5RmGU&3{@B9cm<6?<Q0*t@y{*iWbVsLRux_kTjTgd@!b+WMV|m z!=1?@M4Z=Pit2Zg9=Wor$IKD`v`hytroaoDKL!FiMZc6)s}GHhS5n)q#nrdVo+-#d ztJ#dy!9T(9Y7tqmX2eF3F<SNh5jz?AM><3Xx-7#6(@Tu*V}Y%&vwsQ~TdP}4*Zdk= zQpP1Zrp0hCuudzXQ{a3Zca4Ch>q9EzRE(>m(_uw)7!L(0E1_89M@E=Banz-&CER4A z=)7QB=(o5`9g<c?b&Hn~Ffy^<#J^I<wqTI&{?Ni<)BfokCcIgAL~5e8>r-Je>(?^< z@UOLHQb;(?8N)wfOMmIOR0vOXKw%(}wTCj&rCjt{EJCp!UTen_vOp0(m7SA-Z6yDr z@?uJ;a@?_6IGv&HjRYy+gx;21;*DlE?X>2kuhrtq6x4AQ??{YgG^SL3D|av;O|gE& zvtpAPZH;@&!P0S+eI+|Y>KJ!Q{E|7TjSpyrI>G?}A853|NPo0|{bDw#IU^ch{3#JF zHq=_^5Tk+t7drezsR|h&?2WcX%p~T}>S=8>f>8{ugI=gzsqjd(?7f_XDa0TMDBKmq zK!t-PZj?5y@D%j~LMC8=>2y>m3@ll_LADOoFOE`&d#+OuGUs1PR~B!Jc-29Lky{%J zS}{5Mnp!ITv450!)uF{qKszGy8=IaH6%#EIv0@`gKtvd~cyF@cF+j1BvsJ%_=M@cy zS00VbOuRx%sDh!Yk-#DFp2UF_<~Nq8gcGZUc9m9FGvmD{)Nu{N*5CyZ5JD0GpG>pj z_ZZ)rcnyZ2C2MgcIGDzT0)j+3wnFD%EJ@;W?gRQ;i+_p}1UKMhNCRt8lBI}xfD~lZ zzT}5E1V#@WE##n9Ko15Kh7Dby9W8Kyi8-L0Eb(e$ucDo3eFv_p&%C}>$F}gz8YH8} zbqLt`&gUlKx`PP82mSNf$$$}*F&HvOAfR`Q7fH=%VI_ZXCyE_RO&rfcMxrEii^2ve z%K%pmpnp+=Gys^=iedWbIEcY910}O9(@@mdr53CmUY?GGga}rjk&>2g(NV!y5%<_@ z)@L?&JJH@WHlgMYC=;;e#PJc~+#%a=g3ucgeUIfXUK88OFlubzW3fr|(j7BK)6+XO zF`Yu49r2489xG7`ZOjI^4GRSKR8pRO#|J2SH-9PudqRvVN#k=W#ffdmLDKxSU=0X~ z_EDduQ=eFQt$6|hDM(RFSd7dHfg<jcStN-s6R1K-qiC!)(XTwk#~Omt{_9wwK*hi^ zB`UD3f_JN}!#*tdOGsXf*^DQvRhOlxN#h%1;Z%5PFb^n;oP`dR(b$9y=1|G8gfEx? z1b>2bKrUG5fTud3=o45OV-}F81wE0V#pRLi!<-T4>Vs=GQ0EpGS$ocm^&ZK#+BSVO zn8x|3`HUJ~&@QtJn8=co+T#owCJRQB4;aeQ`y5&nWCr_`1O!Cj_@iaPk<i`x3Y}$) zJq%9C7NiF629;ySGzWyNUQ%j9M#xf|Jbw-506+-F5--=0Kz+y>kxeegQD@#zCx^bq zsFfJE$))*J-Ue3HAcDjww!Bs|;x%amJ;w%QgT>51M-;^YcQlB;$li)Kwe*Qa1<FAo zOPser5|VV_v%Pi&Rx!I2qhgYOIAbhez!c1EtOS6J0BwH&Hk2*_zrbKJ{;996kbgc} zH7h&`4Gx?bQZtoNjEA9)+BS|asG$DnCmo)?bg0%CC#S+Qz(&@aB**~_B=8DQM{Sk` zq|*X%gg^o#ny$t!(RtMd;Gtmeba1KEPV#5gfEF!wjX23YFlnWTGgcr_xt4zxtI%PR z&e9LCoJ#LMU=6X|4UYjdXv7*>1b-{*Ut%yVE82nY)J7#-Ml?+gyc7ddls~IUfKFF< zJD4rS8>x{Dh@dB;{a@g3{$VG?C#~%;o|BV{or~21IB#25uWE6b5U*%PM4cFbABzKO zByXT2=bY_<YqiH29+Bv1L7HT40q7L?Sv;m!ivcX0aZNxRB-Aln^{)VajDPKd2iF+u ztqeS1^5`H)@c?k)+iUa0e=Pz==TCjHTrg-s84w;4m|9YT8knla2Y3$Dph9kA71gLP z903EBpl4V^Ao+R?K#`bLv(|4BmOzO1$HluqKrCA#JR{kK<*Va}&52^u$5zBS#P`}6 zA{VlCQ8OLd1+$?8GD3~pb$`SjW})D3kSF^aI1s>2a)LNi`T_$33F8K^JGVAe#cr5B zI)(UST7%l&Bi2)5XF3eY-qV)NAh98%9+{Ql9n6Oo+&OVt^-V1%8YYY_V)z_frY7i6 z1G9pA2dwjq(O6?8Nz-VF8{`N$bOXSg2+?Sw;sM~jGOG~LKIj-cQGd+wf^@|S@miqN z6Yf?78wr>NEuK}^dKEd&M2;%hTQikp!YIrro(2gNaGfQtaJn3Bz#*_DmpK4B$qC2+ zm<8wzm)#hq)?Hj!;WOcE5(C0^#;aB*V-*$gBcu&*p7;lM#KtrNRti>DgGR0~)5U!n zRX%28aGafpj%zd;9e+zuq6}As*a~sI4h?KX5A~!i#*sHx8;sL)jw6~JhY=X1Lj^~? zb3h5r2)GVhACx75E$Unp5QiSxN7p5eRYH^@Q;QV^&Py<xTSw|}*VvobdvY3D7>MwS zOgpT+M%$IK(IsIqf(h<mj7r`~AOvtA36$EWTdG>zD+?HHS%1+{>zfDz!WRG!h$SLU z1gea>GfUVSZ3r^e5pv@Y5`IBga=78s;Lt&_Ap*`(WA<f0UUMS*fPdW>hqP%dZf}79 zP%ka|uEr<Q-r~wJ5PmV|5WBSjdJA}Mp!ywNP{69M4F=-pR=91by#|4jdk45OjN(H8 zY=a<)#9{hZC4V9ufN+k1M0P?xh%FY}Rzr6M863el^;G~bc*y|IXnIY*Z5={nUn`*e zgmsMvhf$`pl&qCgZ45jjhy!L2uy<!y9vDlL4u%uNDZrE!)2xihJAk8=>#$E?oX%Eb zMPLLj0VI+~g*!&bmrzAQB#Z4j9EC!VlX0-?F}8@DiGN)*Xa<umc&+$UFg*bo9ry+x z4H$s%D@G2Hg2F0^6*Gof0JjIq(7_gK*AA#5inMN^#06N<plwA^r@?o@=&!BUQV*?5 z785RnR{+Mu{NT<U(h7%_Xm3?46u=%NFganM104{9+{Vfifg=nWRG8{owVE(O#DS6I zD~Lrfd4J%C8eIWKK(wgBvJChEsB3~6;%`J!11f?3N_fXP8cc`|B7hI_M#*aMVJ$DF zO~5m%0Knjv;=f?n>eH}q^kEvy5iy*#4mTDN9Eds~qxG#R+7<+vLM8(~>Ai^ss%<E= zJ#^Pub_3~1DC*}COR2X1is2@GLO4FpLO8@QYJYel5gZnKp}FCO4t!m9H10LC2?pvU z03zljpeu+#XXu77W5DWVfyC+t9)VS=%HRmjYw?RwQ$(C_SYq!B5p>WxBy3j00(uL| zsk2u^NI4VFB7`n3!w4v(OJu{#;F#L$&R~od+Od?Hpm>MZ4N%Q#KnZb@QB;_ZrH@e? z;D1hpe;jPYf@p9H?Q;c!=fr&p3gNIv0LTU`+gb-W5F4>WVs*h#JJv{T<gFnx46<I( ztAqiV0Md`(QPUU;3C?!F!z6&Ig~I0Le*uG`gTE^54DAiBO(C*~S%$VDp`yX8#X~}9 zkwKsXpx0<2oa{j;T>QuR!c!y^UmRz^KYy-)mhp1+ZbFnq1rniyn%(I5GV!S7LE*#5 zTgd<oi0n-KQ)j9n#Hxwbok7>$;KCZK*;o#AWXn2ZY6(Y7V`^=|-IIYn0tGFeWIrAP zBN2t*QN5!hy01y%prb(~39<Jj1Zq~;03;#@R2wdp5Z5U;JWCW)4j$hk?gUEad4KJ3 zFecLw;*b_WS*6OswS?tOBtP`}k0=V@Xv9jD%){#MK>RVwQ520~5{ziJ5~1ff0l^9) z-XJKL{lxb%B(SCNG~(?4@D7~cf!J}X0n!OD2=l!*hzHh05|EAr;Y&=7imZ&zoGtMI zMg>E));?ILM9=V?P%Weo6c8wY2!Aa#=|c&~E3z)2odkRmT$&pPERoI`?PA~;Ki}{l zG302+25SgRDPiu>H}+;RXnL|5)Y>5xrKpHjlMq2%0?d!kEY7gOS|^YUlt@^@K}bm` zLh?WhI>%((5Z-A(Gi1(2`&-0C*)>eO4&B4LbV!6qUJ+q&n=={hoY^4BwtvRX8R0F& zwsr?m3%g_O2NFaAi-z@t^$z3UmEfiK(NTN98Jii5NLC*Qmn0v=TZbIO*dk^_W=2M# z;@cy=8e9?`JN>_dBQi(>76;)9P>YPITX#-1XnSi55Q)Sng7qX6VHg5MhT6~!$g5>C z2`X4@L=+Hjg$NQ*Clg5ybALp#4A>HVVPoJ4yG7H?#uBsRI*hMDfX-lS^gKu}Ky!`z zh^a-y4r`7i7mQ78AOex_2)2vZDZtKwBoiD$9fgMQDFz%q8v#|)3hb>qN`c!>HX2B3 zhAXiR0j#8gwL>V24vT~17c1*ie3;N<26p0|%+=!RMGg{C!j6bJCVv$+kv?5a!>I&c zL;h=%@iPd`SSEKinwr+Am{ah8`E$0n=Y#}tIyQFV1V=+#NL0I_nmob1$~YA}iOW#1 zJkYNl2^<}HEO-Q9_$|6S0%_L(f`PEJtU(z7;113-1G6#Y2?C_;jc7Z^LB&TME(I<z z>xn3=aAUN0i0|xdI)6sT|3?2|`r7^kBzH(CqMwM^kpdGq)f`Hs5FUC$@pK@9$&PNs z;xTlNIYjIZ+Zkcv=yAgV6ent*F<8jZB2Je$e_|XUEv)QF`XUw*xmMOy&bPDP0;gv0 z0BMPHA)A2!)fe6AoFY=V&~+py0WyI~Ca{JEV=(7FK-F5ZHGiZ}cBt$C!*uwOfx|;C zVI)2%BPSDCCQ}F-kJKNW2uF$m(|}pQ83<=1tShG^B1wo*gE#>u5~D~+7c3jB%Ix$! zZFaWfW{e*5BP0Dunj#ql*apkacsr_rT!+Rf4@9UOkmo=VAgLX2Ar29+(~wRT5t`l+ z(-BX|bn<|}cYiVOWb-$UyfJZ7ut+A%*zlG&*or!~B-Q~=AoM}fkm6*~km!RIMbag% z2sjO9KDlT(=cFuTXIT&hXuRlP+SpLJ*DW9$flMpV?HbjA??!Z$%nm&Srrn|q;VIn7 zUQl!P&}k9ACF_H;1vm{PkVtd@m<RK0z;E$orITAC4}aQjyKF>{(OOPLatabjgBfop ziT$mZo%x1QE0sagAE`95WDuWv0Q+5M!VCw*m5`-1Ig&uOn2_M4fVRX&TYkoIBz}xP z-J+*k(jO{&?I7i~v8YHE0{$h2B*-oy&Fp*;vKVkv2%2dk9jcUkr7Ac#62Fg-E!b@Y zT$HG&NPjAkn85eZ!}^&sbBPXM=^@ElM{@NCH%qFu!W$rikWjvK9#{;?bA~!~;)`Kt zWH%T!d6J|R*nFS$JV+hHB*HHP`Xf3S`}kSi*$nLP7=zO;7#`b#%tz@Il!Mb9Y9dao zg##5pa9DbzAaz(gI(nI7riR!6ceW-GjI*d!uYXWWWL`<)Bz#(wJz_$N0x3lTOhful zaF{<-PK2_d?(7FLPj&8yY2vd)*wavxp@QJ7iHQ6q<ck|j?ABJ8l}~?Y@!|+Sbq0|O zKSI81R;2RUE(O*kx<YDX<FFHE4OmA6&p=s;g)q&?3zj>AL!|l1M(ctBYAi)uK=y*1 zDSzxMWE|;cErCz64p<m{4_t(2pF6{86|Q!6l!+)cVouVEC>+uQbhCB#sL^$aa?OUY zZvp5a4J;Tv%Z;at_1-$-?$ke$$s6)7F&xM%wNKo^vK=7{@|8QMg<}~4#}>j0h(N$i zEGGb1To*DXGR6`~?&2H$(_txtn^<_m(|>3|OzsNrgY+_Sy9HefoN8o_)CLEU4c!!w zIWSzXGBI;)*j3E!)9<7`-2BR^v}D%B(j(t832|uoI;{rlW*sj^VOR029Crt6^T!3C zB7F%!JR!%1TxceOuZ$5x2DW39*s~yxBzu9)fuUn?+F!)d!%`y3W=DlQv&Lzcgnyq) z<Aed{*#-;<Oo<BQ7DWMI3oJ-pm!xWO-i#e$`jXYrqJl^!(aT#WDv|Oh)zCOaQX>&Z zYOzOwGmMuvHh*$<B3&WW&sp>licV<5`XTzmC$!F>BhSxZX_xyQ0_FpGAg#K?y(X@P za0IF7(+SCtCNru70c-IGvBm?okbf50M}Z&};cPOz8Zz=42j=w#XCty~Sfygx2%6w{ zV=>^S36W>nI6{Q1(+o)K4c^a!+$*(%5sq?XgKyx-#Q-B1W<wDKI-7GPSw%_*AUa9+ zMDSdC0lT7(nrIFO^(1+m1Pc;Gn&<?43oQy3fYAF?0|F6Em`wx*Cd!tNEq@`6id`XN z3;7|2)#n((Bqo4w+p@Q^#u}%xBD5N-Y>emvyiPd;X9-LRm!NVbiGyhgm$0)rOGQBg z7!-hRfM`J$NfArVOC+nZMi6wy*zrt^`GMDiNRib>-G<&u2!=z7YNFVq7*FBAV~1ju zCX5Y|$g5tWN4#iR=$r@Ccz;tH(ul#42+&yPCM5p`K|<yLs57QM?m8+1y_gN_*QjP7 z6j_AYsAQ*@6oyRJn6_6^m*XQ26K7Z^;i**K8!!Qqw~NI!i8LMDp70AW`iWZdO{A5P z@8&?67N82&%N^fJjFlBKf|Jm@I6S1S5v<XV$)VvJ$PVrJLU2~w!GAcbpfb5}f;LNo ziI6dDTjv{+BTclx){~26SmlgqpnVA>hy#6)?uNrs2nQ8XD{6=0vCy1c2AtFp{llbi zP6OXkm`Lq3o$O>W*atMt8|k1$hppF=ScG~BRQEKVcmUJ2#qJ`DOst7GALjtb&v7oY z+Y)Ff^&P<G*v-UsrGM$7>u)%-(Rm4+8w&;Uhe%0FmGi#{$&g!>iSv<w;dG4Iloi5+ zd>v*%WA6yYXPps>h+4doh-XF~9PVe=$Lw1wd<cJ#dJCq@TY#{lohVs5wcS3arg{s3 zP0`X?ZH)gG=@xq<1DvdNh!lIdBjOOexQLSM&`gK*!{<{A6Mq438zTv+c0j~xlxz&D zqR<7c|89pFm8kPeBnb~&JZx~YGP1~lE*QbMS4c+OC?HA_u<$K8^UktEg@NVN)So4* zJLx8>NNi*@SYaS|WIF-wp&*J8v_c@4f+rRYf12b3qPwV74l7O=p-c3T*nqSxDyIms zSFk?tpW^@|YkylHMSR&}1%m0SBTc?jLT|B)pcLr67W-e{0+yCM&Ek&)Rw3CG*vme? z@dVdcWK1JGt!N~bqy^H*iQyBiu6dm+a>PE4lxtLw0DvKqt1P>M(R9MHU@jyxlHrsM zGl0S17n7q(&Jt-mhEAh%G!5^9|DejLQX(a_ha{<f0Dm$fROa&q0z`P;@l}ZnJThwG zT4#MESF~9>+pVfF{s{GwU0?g{>=CL88!B7pfZC9wf*Vc(8C5`JO%!iLi;AzwSt~kq z$hclZ;fEC0GoXh_<4fqsjG4_^Vn5=}f{PPGvTa59k3-pzvqt`Bu~`VbXEez16wELb z0wF70MSl)LLohNR!HLE=Gmv;2krM=tV-C^zb@*YGX9B!QT)B_dls-Iy2aO*};wB-` z3_R~7o4Pel0}HYiL_55n!6qpWW204Axd0^vjUNGMsiWx=!;?=8rVYW7#wm-S7%plA zQDQu@`luyr9J52`+Wa$A;KYZ5S(~U;K)QglNt1OV5DXRe7A!5UBF5PghOCp3A~Xbx zi&T@7$s!wnol~2LUv)@arV8ZeG#riT3Wbi!y&6BG1O3G&M`SyI0DeOJmh_=O@d5xS zI$QjPivg-iR0vQ@wh@Sg!=>OLr21!Ya4^~A<O8DH9S(%ppJYWBY$gLUB*`QH#0}uF za4rdf3<ALH+`GOU(!tFTT~tV&O^EkqGg0zKjDuo-O;S<WCZsyWZ@5bw76+e6Lk5+I zBv#{5J5bS@Gr-=YMKC`JCA2QL!Sk&`pU^<4HSz-TdO~pdpW#Y!eURfMniPB0$&p54 zXtl#dcom(qtul5Nk{1P?{X3v&Ct)<v1`^;^OOg@h28FEwfE*(Ys1vxn*mOrWIfh7# zqNdP)2ti)Cs2Mi`X6x|EDoT_Zmn&g~5-uPw4~2|j)Y_HBqDHU-N|14dab>?9r!2ZO zu|}~-PvW9EZGxCI@ibSO5q=kAl9O52-m7R-4S)rPAV<O_uf)6vw-ls<e@J!!$tlhn zCO;cssI^E2Cvu(`@nZVu^k(WN?9IVj1Uf)}N?p{UuVv6c+9WAQm~xTQvX;UMvN<V$ z5>HUIK>;Lqt+fukfSJ^}2#7_4F^$s$f05^pxQ^MSu1@QO9VxDo+0<v&khMY5RJLCt zJK3lUC4`~R)J3-BV9ibanmh`)&Ps^@L1k5Ku%_-~>V*8z#todE2tZO=M5d1GAXpWD zoKr%A;9iM&<Eu5!NWxfgGFaz)Bj7y@0}|{TCJ8@EA&_&L`;e2-4hkeIr(hGrz;+>X zGSqzuN$4}bV_)1B$w^>0DR=Fh*a=QfCADEu>VhbsAjOf~T9V|!W)epm#gD(;1V{U{ z`2-z2G7z~BcwhEI#!~`@z<eMkOf@lovIW$qBL5U9J(5dH?qqB4Q%x}dWu3%Y`{X{Y zOK<`wg=%_n<ziWVuuI=5S1P3GprQaaeKbg1FJyZV`=ZXMwvS8-rt{#z7AYx7F2Txt zBVn_Oq=M4NGCF5(02UKn2fQbyZCfMYECD$;RPuw^b;hB|K6X-ZBE5!)rfnU6Og#Jn z65VPS<vD@V;3)MSH7Fd}Suj1NFb&8YSsPNq&gB5J0Y|~Vq%sB^tB(Xo`f<>@KD`PB z-MNGfm<DIP4t+f@I<q1Sf%(_jjb=57`7{o(M{FAh$B6T>Bjmv07y#*^XtP<Ub;#Mq z3QN$E{#%^D%pu`ygI~$^aA_%ju@n{?$T9--B$o!uVs_;cQTE`SAqA;IrAw=j%ui4P zW0Ly>$X!BrAzIm4tOx>UpjE|nS*#oR7ZtD^1yLAHrFJ@f4U9~AYl~ja-dC3-7K%F? zTVyq`of8<7V>8YqGQJF3fK+msffL7~!AztjS<9_!Krn`!r0%*Fr|<)R@Hjk8;v~T? zpYlHP-1z%JAxW+Ws0}?{?;><kVL+Ryk#M3jVN=2m{Dj~YqSc5^B)zLp%?sQCblL(7 zljaGu+Hj8m@3Cj;>~E5s0dL4lA)f{34_}phNKkER^YAu^HyEnGZgG}@Y)rCbTs}#e zI4N!bXB5KN?gV|pKtSq$l7B+b0=~dRiN3!9?*n+!)}tMhhN|Am1(Xz0H1H0==?-D* zG`WPEUS?550z*#aX8<#Y)9+COq?Cv~YivlW2OMA}>`}Y03BKfT5ZFybiAasXU8Cxw zkEgKCtsw?27v-pw-QfZhye^l=0*2_=8p*1inp+bPBQH7=z@~<O1zW5yqrkU!?UPLn z5>r@c#}kN0kZ^{huAL$slhc{9KNh`AWDmC%)0Y#AD(&l6vxDA*B3d{Rrz$%DQaM2- zyCxwTM(N05$Ng~1LuqG2f0V9S7x*5Oz!{@H6eEbN3>n-cA`!9eI5pHa5yS%V@k!!< zBE`w^CL@mWU336{b|)Z1<GTSWr{Fu8oQ#3iuqvXzw&mzsEu02T2nI<9U!l0k+b$T1 zR3d<`aX$wY9Vkm|ev~wyPTF&{l|`XC897xSu;yYFn^3HlFWjIcv`;O@t!7I}E-;Kv z+K)tEYdjk9))hl|_`Do!svw;oM+tjfNE7jGE}){+Ap+`u)y`~pi6PpQ+6+!V$F{P| zLgfSTQtBcsd`LkA8Y2Ellm=l(q#85~Gu$_4pnB~ZWMnpak<14RIzSv3AY@Q4Qt~)_ z<U6|7mw<{vZd^0sdbqNrZ~-qeFQ?sPU&!Ee3Y=Un95L&5m5c6()f4N(J2iV#y{o?x zVM_MsDsIYuK+k7<lGgY|F<=dtVlxIs-uCsIxC;{cM2pa>hDN#Efy#83Rin4ah{mfz z{#MQ{@GUgltq@%dj}bst0Vx>-Pyi~(FHXST<Z~qFYRlOmwpgRus0xq<=B}UGj#Tm5 zWj3>NdNmn=cvT@8$V36A{xXxwJ&Qx8_G%0Gi_sE)a%MmX@C?`ikd><VMijELlM79_ zD~9qF%(z%P-`eTtxZh}h{#LQiV0t*z_-uH@<X?2SdBEzt5CocBJt`ifbJ|h5=u%9$ z1k6h|D5c3<2>}Faz?5@FrC74B$!?ID)WOURaarmIaFuH-R17KZHDJjc)uEQN!WUqY zRN!!b2D{?hk!ph_I4SUfdIl2ku|E4cKU_)YuoV}_I(3s^8Hwv1N{Q?VViv*q)94P2 zQP&pWrD1lF`^))pE+6U4I0a-Rk!Ixt7xEfO?4tw;$FDL5!`U<jPFAav=g17`dgPRH zWxm4pFLQE6plcbb*cZ4peZ3W_R27&x78tjGwz!lB>xVy7^-z#VjsaO5nX*Zo?qtE< z*I~3=)k3`<IF=D%s+FBdjXB}61so|rPkSol38H5TK{YCb0lf&XM8gswDqQ!3V&`T6 zoEh*zVvpp<Q5cmC1rv|P2X3tKnE^Sr<TevTaGDF}9QZpJE+*oNElAMK4vH_?Aa@FX zqZ$}M8=ym7IDY_2)O;uFC|{pa93;m%BMaNbq7;qfJ_(hegDU{CH=U{s5(<z2(e+*A zFMu!_>nGxB6EV5i2|ma~8px-?F(bGuap7_Y?y^DEVLJETbzm;GXLP!JD~GS~Ax1)h zU3L-=7J21@FmjYRU?h`)R5s2$Ah0Hr)hi%>_B{<0qPH$nMC;XkeJ=4y)`_X}Scxtt z18_sgkS$CEI<cOl<4`h2?GY(})K#Ia@K>}wBto;w4i}}q0F5|NUH1t~zAJ+O9yWtc zGu7$FvPpVn_=+=4QA$G*niGvWL)wv`DN`;+nyJ9T=*JoW;-@Yq`i70-GvufuxLSXI z84(HyP9soG;1FN|HHL>H#^^xJ0H4UVsGUoNy~(C>WYMcgz}8rXQC(+gknF||V`@_^ z%7JVg4~ZoG>KIei&z&=^?-IhycixXZ84zJmTiD9TY2=n4JwZ-Ma*B&nN$uvr?O2a> zUz;qcmCz&<7GutVwGa@mEKeOg?tEE)Lv0fZyP9wd8C`5;hXqRrtT=a+LkqA;-c4}W zxb>xQDf#Mv7KR{?i$aI&OeHd4L*4rh$tFMSQ}x%DxMmKm6u}~K-<|Adlp$diXnGWI zxq1a4#Yi7v>dwit7B~Ht0P5gPfGVT(IXR&Z!enPVTg#Hr2&mUNiUs0H!kvMC39h@~ zIx8;PX`Jwg%k7GT+Cec?R>KeRQ@G}c<WZ8-$qmIvY`7yOwXX6EID@WpX@MOH`VvMX zO5&s<U_??5sQ7Mup#bTgsDGwTxRT>bEo%d|Os2f!O0934Vns;GW?>s=CKDkmPIKcD zyUsx$9N6H95k8-UPU{p@mvcLR#*KJEuM-F`Fpe<v?RQ+I1K>s7K<k?&urcukC<aR) zy=1AO_`&n3eZW@)xFrf!<=&8tl#lzSL^6Z2MHVWw0}Y!kQ^N+KP~3Tp6kc?``l0ca z9mPemE<LMluLsxUakoVaibbf=@`!wLth3e*9tH?vjr;MO_D(n%N6#03wm40#27I8L zKRVh2$48g4R9J()t%e*@q6b)Yh2jw|Wa*QdP&`^GU+~uRGWWy4(o_x*<}vmRP()EL z2^^RwAnSyl(O4P8fg^#E!csvg`+@=rai}XJwpnIPjs|Qm*)4L390&{kVZ>*}?;_O& z8@D7^!g3WK8w}_6nlSc%HYn*Tm^jqSU|WC>lRA%h3moO(`d*SB`{X~JIM?HMzBtWS z6gIBS^R+YC!J?KR7Wu-w4G9Kk1r`R`j&&tlikylF%vGb`BVy5@B~C4_0!!FXa0s$a zX-0DXd7s?bxOCR`FW!?(nS{keo)Q%jv9CKc)Y4zYLQXU|7W?6UTzXeCyJ9$ymRtkb zR>|f8SUTPwcM!Q6i0dDL&CJl9FBb7FMtnHnD4w5lRd8^*whyxc%ewU0S?nr?tRq`g zIRocnEjusCb)+a<R8My9LPgpDkhHIQDvjff7$+niMc=cBBfwe#bpsyynh$~@YzA4f zE)(nX3p+zac5V}Y0)`98$Z&N)vvtmqop)00`rDp3*||@RaC*8c?!1rO7^=D8TuHp4 zP?Pf}Z47b<T349V24q2DD9k~C@<`(H4#EbuQK{9(>?GsXdD79qBeev{0VSfTonyEx zMs@~xqUfslE=`b964Y5l(z!~Xe}^whtQgk_Y_I<*lf>_Tzzgst2W+5k1&M}qxQ(-M zWDAp>kY)no=sZR8gt={l4RI1f$8utKql<cknDR|$!yB=+oDEh|HEM*Uu|nY4QD=g) zq`sh!$+iG`CN4+t5L3X(Ue0F2oy!O=uIA)k7~J>b(+HbT<N^kjsBG;j`|geR){Dc% zPSkX8?*;gOB#9}dHEs$NB)#W5>RdC93d0t{k7rt>Z#(iuSl49~oiEm*qy<0;JA;c_ zv6-kO<=P}tZyGLJpjI%&9@^oe0;dWjCs<LY>H9Unqbc(t8bP%LaW~eP>>EmyXG`>b z6{;^9b(S1eaD=<K<c0tk;3I5NyC8+L4UUEf*rF1D!A22w+<X~r`;)FfS{+$D#hK7O z-iRqesch>wg%N$yH!Az<7+S7pu6-{krObS%?;1@#L=2aLZ<BUQT0-itAo5jyzHTe~ zI@HctP~88Akm&jxLvL1ciaC|t*v%{)UPCreO`S#y_)l3E_i5rv)RohckQm%#L~fOD zCj>ly=p4WXtt7JqLF`2$PLs&T$IZf+<8+X9);RYP{mP-`E-}=a%nJ>SfSSrwhn zgW3l~A(14xE)h=iy@tNlp?3N#alhd7zvLQ9fP56H>!Y|xfE@4+okLDsvKIwf<~sSt z_r0*cWbJ?spk2B?wbPePRd$ZBCk+d8`H$~^oFrgP!U>3wn5lMsT5(DQ4jb-^i+NGT zTxnzX!`>t@#>|}tq%*MuPQb5Vacq;~o3;4%P}yC^O6l)8%g*}bZnxH+9KMJ{(YS|1 zyC|NAl>*mc)h=_i(!$UtlPnri=d!~Nq?@2#?fcre5!t3X#iyVSi3N(jH7y(6uKQen zFiHy=%N{}_4k+1O;NnU!0m^MUS3}pu7w8&u%l5du031>RtQbMHuZDn&I%@+eQo3x! z6FkcIO}0)O@g^h=sxK!anW1$8ELMH&E2RnAaaT2fW92iOd@li4-%;f6OQE<p&_}z! zchG1nnRi4`bARh;b`dbOxh45#D?A)0ehBP9f>DDlqc5We3Ku(rONNp$0xWEjd^jT@ zJ;Y7PbO{Co0e*v%k24`Bjnk#LR*t*m_|lqyc$0j)2L=%rdSiNkN&7aL{x%=*JkrXz z#IJIb*E1e}HMriSag8V`vc&*Ob{-b6AooC0*aEsjpfdO;6#623yS`!&M}Yi8fMEi5 zeHk`*H(Q;Z-id>X5_hD{mk#%FIwUx?h{%lGS0`p)T++I*ii%{atL;}{W&r&=(onmC z5uk<u8d*oayOHop?UF|dpUAQcMm=$hT`z&b=^Idg@RF!3rV_ue^=MtLgqUGCM=r5+ zg0oaBCkx=YyHGE{-mT+wT%=K~ZpiP#rYF`;S`wM?Ai;zZqHp@78aVjI4uXUIwPrvs z<g3Ch#kWZNB2a@Km~ZIbmg~}Nxgid+?<VT=@rjUUQtv^CC{rQ?gS8BRV%^Y}f`JI4 z6kRxfov@jTH?4BXL2K)?vRLx9fxs@@YlPb1at!RW%9mIH-Vl5Th;x7vydihaXE8F1 z6OIF8mkfu73HmZA-$7!C!@{fWy>M={$0Nr_p*Rk{#+c2-4Qw%y9)$5GsfsP#IZ8=X zquA^!P6VeCxbp=`*a`OHxC4{;30bvRQLGYw<*dcYVV%qU(7!Aa_C95Ot@EzA?<;U` zHqj8GHLbIPm<|fv&TZQ#`dW395?uFJ7jUnGi$XC&rSz~@32&3QKw>Pnq2ZEHEks(b z@0LJZ;ZavTYZA<J83G<{%SG6fc{s%g47~9@kA#AV;{?74494e}ppmmIK%eVgZPva8 zyv<Nb^pp2BC<d*s76BcslO;AJe^B~bK2joVE0MrUd>K8-ZED2-9fwCAQOpo*x)V^~ zOgBdENr>ha<r+)^lhuYd_h53v0`uzw)d)df?hyLqW~#-biys^xDTdQ~;EXu86HrJb z<2pGm^|Zz%mzxuWJw@o6?IlI5^35O)A@Cn)@NM`mLC^hdtetOCL1FtIf1}d$X$OuU z6c=%l%N9Vhu<x97TzuVVe|<R#VHhQiOUi(5T`$5(jIIL0-$z+j{!cc{%28*VP+UTt z1okM_ZsY&%LiA-Sq`h$`I)!lTD}Il&5wUj2M?(9NshNCL1SxAoR}<k$7>Rfik!<I* zIDYOjC~}=$YV13$e8IVWe;{I~9r_a|ggbRLhrYr(8{S5>x0nun)ojxXQ)(1_$pSa9 zG){QN<l`iBpGgb$2p&vrs-G&pYRc%0Q^Clj2dqP7;Y5O+`2Jk2FL$m}WQY@vZ%T<Q zU)=OJF9)tr!sa9&&-|xt^L1y0EpT42O>h9X;D@k3AU6mFxrJoNe{#tqMGC<eYF5-x zP^XV_iMC&<A7gJDKmf8ju}2!`VEF1E-@@t}Z8-Dn4K^`p^?XF@n!J|Wc)UAb^+?eU z7(0owh7$3$G5M1-Nx65qdhpMKe;)kv;GYNoJox9qKmVWq+3mkqcKul!w>)cR<GP*e z)@<IseeH^;Z`!(bfBTA=EgRRa(BD^_eb)M0cJAE1%|BSbb6dUQ>>D?ob$b89;V;AP zzdT)UKKloQ?Xzg(I~PqRza#ns(VvO_TJ$;5*F@hFEn7U993nbKbc!hOUndn^EV@ec zRM8gEPSFcQKPP&P==GxC6un#YLD5G=pAh|>=qsY{h?Xpwe@qS%9Vt3dbh_va(FLN% ziLMoG7Clq+Uqmk!y-M^;qPK|NA^L#mBchLsJ|p^~=$}QCy(W|WMTd)y7o939qH{%$ z5j{z?L9|Wu9MMmUZWsNc=vPH=7u_NHkmzpFCq<v1{coy%U$oEC$>dPcv7%L?#D6DM zbgAeG{FhWke?K95mgrW|ZKBtT-Y9yT=)I!f7u_ZLE74~~U*(;PmL0Na>7#b+SofSo zi|%bLU%q^@Xurv#4U<LtFIx27rQSTX)-2QiFLLu~G#9)1YMM*j{LnK0m+ff&>oRi} z%~Q4gi<Y^0J<Yw{d=<@o-26kD`?~oZn)|uAdLKr0fAgs{4{-C9G!Jz14`?3b=C^4s zck>bZs(G-RPoa5;o3Ehx5I29H=Amx>3(dpaT(zH?4|Vf8nuoi2JI#l=`Fk{vaPyyO z9_i-F{nb3m&1-2M?dHpA9^>W*X+GS|Z_zx~%~K9g^Efx3OmoJ~m(e`l&HqJng`3}` zd4iiKe;=skiEds)^CUNKqj|EMchWq?&2P|L>E=lXskzF{C((R_n?Fx;wVNNHd8(UV zr@6+>6PK%bnww9gdAgfFN3(MC{WNPgzeY2-dBVYJMmMjfncRFS&Bo2&rJ3FQD$U~N zibK?F-FyPg&drz5Jj2a9XrAfjKhZqP&Ep@Uf96^@A5ZgaH(yNi95;W5<|Ezw3e88k zIdiC*=el_n&GX#+S(@j&`97K#xcOz87rJ@eVQOCF=9M%rcJpUwUgG9^X<q8)muOz* z=CKb|^U-czLGv+g{xr?Uy7?ZOm%I5znvZky;fJevg`1C~d8L~_Me`~*-%a!JZhnF0 ze-qq1=3#1H?dIh)pXla`Xg<l!chS7Y&3~l%WH*mKLd|R4d@RlD+`N_MQ`~$f&8NEg zd79U|dDM|=KF!U?&|K%{3u&%L<S%`Pn(q^RO!QBp{g0XzJIgL#|BOu=b}m}{gXX~p zAM7rV&?A-TGSOzyPY=5+8Fl$BJ@QV`f1ioIDB9=fL6^NoT~5&>YeW}|Hi&K=c3C>= z@_Ie;YoZT|J}LU{u*<Shm*bC-CKH`2dWz_I#|*mcJ?ip{dgS$@J4E-0zBTN!c z50}mq715QVn;t&svhS$N?Rw-jqPL6wMD&GWm;FXv_BmD>RJ2NTzG(figD(4zf4bbN zM_w#?qv-vjzZrHpVASQ`^~loWCX*S_nWAfs8+18v)Mb|*dA{g%qIZh^V%X)NQJ1gl zk#CC*nGqL=E}I#2Sw8CW6ME#CqT57o5q)Ub<>2usdgR-pha5kdoF;no@q;dhj7QNU z&lKGzdW+~o!!8dQb@`$m`I>0|e-+|2(FH38T@D>}*{DaJA^I878$@>wyBs#^@)<qy zInm?<@tWw269!!#I_h$b9=Trh9MNk;?-+JDeAMM*dgQM}-x3{sqE_w1L6?V(x;$Br zJWcdG(Q8HT8g@Bi)a4U;<Wr*Whz>hRcIHWgE=P{KT&+j06Fpn>YSC{Gf4dwt>hkA$ z<Q~!2MF*ZdnXEo}(B<e+mn-zh6Gb~jFBiRa*yWf}mp{=XcZ<Fx+WVBr<fKyuT^>H_ za)BPXOte|_BGK!IU5*`(qDSr)eOa{6%E{#9m4hzFjk;W-M=lpVL-ezvHx0YYjJkYS zkK85tf@tX~+3BkWU5+1he>qQ&Tq4>adV%Pdhh0{Tx_m&7{DJ5*qVI{0dc>g138OA& z=#fW?t`$97^xuYEP8@Z4mmax8bdTs8qC-{>x|}rX(&&*hMOTY<h+aADa`LFl+x5u1 zMR$w7B0AvIL6=iTT`E12MOTP!6x}xLvU1erH}%MGi#{s)N73GEe+FGvjk*Lq(u%GU zZ5O?K*yRzUE^pH#?-1Q3`l4vx(*|8ukGibUBT@8N(KAFZ9d<c&)a5OD<hMj05q(ay z*Xe^UYerp8*CUPSaiXoFpC5KPZPevA^vK&qe=Pb3(b8(r<@8aPlk~`H(S@S*qFaYu zs!^9W>yfvKJ}mmIe`rZP=u(fmtk5GXMdyjG7d?O2C5*cKnjU$p=#NByFIpT1UE<j6 z(Icmb&J{gX^pnFbY1HLSdgM1me<=D}(IgJKG@~xZ>5-E}=ZLNqJ$Kk8kBuum@_Nx7 zqECqaW!R;Rx;!*ZCP$01=t|Ku)1XT`>hdZ*@(ZGOi2h9Ue^0|M-KfifjUEx5Cc0F# zr5SWNW7Op(dgSGzUl;wM=(EEvXO6lo$vRe|6Ge{{U7rVC&Kh-jksf)8=vPE{iatH; zvUb$v`+8(anM{rqoguoW47!{>HsSQh^F^-{y-W1*VV848UH(~*d{1<ED+MmPq8)U3 z<fzL{dgNK6e^-j$Ci>{G%cDkJzNAOKE;^voxe;B|4Z55=HsSQhGex(F-Xi*=VVCnp zUH(Cjd|9;j8M3cL=bka>a{j2xIz4iO=tZJm7QKJi<$_U{zttn37cD+hdm~zV=Ag@k zqb}F!k@cdV6unOL-eH%E#>SN%`IP88qQlP8IX-L9f92v)mn-$ilSDU*ZWsO5u*)T* zE`Om%{<r9xqUCFKZq^RETsrFV7(H^8Xq)Kg0bT~7`9!}y>~h)IAkiatiM}9OdbZBZ z*@G^R9vdWj<Py<F(F;ZYW7y>}qb|R%M?NC@tY~u1WOCd&gD#I9bvav)oG-dw^gPio z4!c}F>heB4a(}1juSNeNdgvnuT^={;lJv+KqQ{GF65T%Ra>dx}(Ia<=?h$=MbjYIy zU9KD(Bzh!^t`OZQx^39ys<GLlN8T;ETl5vt0p||7Jbu(=wH~QOj}|>$^x|QcCyW)J z9(k+ik3@ejT72H1%hjVUC+m?@MHh)Sh+Z`8^2AY>H-G4nH;aBx^l8!ehh3gD>T=Ba zlgSFvTG2J4UFQ$FTr=wOT0QbhqW6eCCi=#(%acc4j<`T#Lez<#AliAspv$$RF0a-j zuM@pf^yi|l4!c}8>T>vn@+U<_bd_kwg@Z0n8FhK39(k?ke~RuBeP!6?siQ6jTqG}C zv_^D^=zr-K4Z2)E>T;VNd6npGqK}CFaoFW)qb_@2EKg6gQgps(!^MLx>&EI;kGw?m zE229^pB{EuKUS}LWXUDk8_^k}Yc3gd*)UeGdgS?{Ul6@h^s!-=jk|X_&_MojJ+t^Q z(EX){ELyT*`&PI2nhbuk*VZlDHvRBlE!)0%^MB2ocK+~RF5S8PCpK-n_iv!pQ->w? zFt2e(9d{r2fQ_3r>qTpBT(@Dz_POS8;C$yW>^S)NnYji&XubmvJN~$<zI?s|4?FHY z@V;90n|JQGWy8+7CUC@jCot^z<1YD;^Bs8Darc4u+P3b-O>>R?@cE8C?D*q;^s)0D zcz@V&Fz{(}4Sd{u2Of6(ald$Gz5@?C?mqCc&098Y-FWj{qn|wA(T5!epS^0Xflrz5 zz{8G%f%lug_81B3-3MMdb>PJ_bMExwc@O=FsY4&Q;=(OEZr(ZbXua;V6$=okbIhVF zkkb#I_sH#ZR$uY#?K?Kk`QeApd-$^#_<!LKoA=1)Oy{|}T7VLnW9UacaOZ4z5OyE< z+z0ZUO&|LFsY4&M;;Ky>wr|_GhX-vMyHB6SmD3gY%*@<taM-*DzxqGotQ|G);jdfZ zSvz{(BR^&8$orgd`i@OEY}$4DToX89-V@mLz@4}yQwQGsK%ThiLqB~E&Gz`GZ-3db zrw4ADW}7~XTc*xp>C8e;-1O0(`#_(#slzXR;T(?fLildjYxj|Foj&pc8E^X7KQ+hL zbF0?jul9WGpP6ID=ltxY^B($Vrw_fXu2$F8mbu2?f8OKYw$M*MVBSN&Y>rP~y=B|x z)8^duhs=BYS1<I_51seW|8@G%2Y>dT-v4{f&7b11&M}QQEOZ5qpZCyjoNM#9t=l&D z=1*~2=NSJj3;pz=_qpdo|N2~;?@#alJ?G{(^Pa}LA3!xTl!v>I{GJC?%}gKrebdL@ zr#?Nb7R|Zt`^|d>A6zKsO%wLhhyK0kL+@8tr=f55;PW3k?>T&Qp`SkuHh-8t^q)>2 zdSCB-wFif83N|^%6z+Kd58bk<BY)xnJ#^E@{;P$CdX~(4=)aym^pdTc<_tIt2iWt$ zKebR^-+SIee|n)yzR$de{>(y$-gn+Z|DWkYFD2A6Cj>twv^K}^pIhjDPxF|k5B(1d zUG!<_*z}=4KgSWfaotS|v45ne5B|l4F8MT=VEWKsTIiBbQ=-#{{_-5w^VW4YuHU$B zA<*3P@xQUqRX=9lLw|Fjt3D-^I>*r8nq$>(e$I{Sw{Kkt9yxvd@6Pe*bH?~iocGY* zTj++LH1DDRZJ`@JC8RpX(BGe9!*AHMO?y7q_@~Z${3X*fRp#FCHGlISdas2JecHT- zUOLCnbMo5h^B#KH^r81KhCj_GpFaKp3tja*@1YM|=+MJx^qvoW&>TZA#3>qD(7TVk zeEP`y%*_5-h_O6<1`nI#+ZSXkPapb-IhcLV(y^wQtkcIocA@8dn#nqS=;Ic;>W9pG z=$ScIeb02tv<!yn<A0yL&~rW||89<<Pg&^D(~>8q554jM6fwiYzx&9m{u4yZ^cmC- zq==b5beKN$zSgH}*6p}qAyJ;`Q#f;>Qf8WOI(_J~7P|1$eADSeul)~^GSgz%)5kw= zp+|k1Z#sSG^A|ewG~aak&=)Lp=xM&`^r0_&00rFe{O>;UMGbR}{Qm$M2Ts@8z5oD- C^Kzg7 literal 18407 zcmV)GK)%00RzV<BZeeh9Xm4~Nb}|YA0OMVpy0Dji#Zs(**CEw~jvtE%00000000B+ zoe8vNRdwgTS49;w1q#T_qnN5J3huq<+;i>)3Y2+J5l|FCutqFXRB2IasT~!Qs4)l* zZ5(<ft;QrI(Ja%>A(1wN(ZnVp8tfzvojAoQj)_KNcmIF?`ykZ4@O{O5(rfivU*X16 z@7;6Hx##S&hyULDaO=!ywBKmkkuQ1ww?2F6$A0|kZ$J4J?S~K25B29AqO-OhcG0i? z`J!cy-1l!j`K(*tb>xhH`W?}hMcZEbnSFje9J%=e8-9Dk^~)Cdrzg&Ibd~4_*B}3; z$K7!4-@o${9}btl?Vb-V@=w1$M>j1RjrN$m^fiyT^@!p{=l=V5uDR&1FInoJ-abcP zn4{Un9X)4`-ZV$=6D|9j|9xe9!F4;HG`j81dse+>&&B@f*XHQ7Jv#bj(KFg-ed@pb z&A-ij?5@StmOYRBgBkzyOQKi)`lsIUyw7~}?ANSmZ~Mr8PyE7+e|o@@(ddzPpY)sG zyKCbMpZ}wG?zrS1kNCw!{^`+k^oHk*MsGj-r8k^;(yHS&-E`_57ku)}ugv(Ti?)wO zYp&b(RhQiK)~DTeLca8nZ`^qEjDPz5J4T~V-+AU`ci;2cor}&t<)Y7AcFF5z{L?Ql znHen}?dg@DSu#3k(Hll9wrt!nyJE%8*|J!<a-Z4R6`MEBu6W_b?c2_t-O1nivtr%G z8#Zs9`-}d%Ve?JT-m>-uv&(sI`O5$J#nz3_-?Dk@#+4I0Zr!$H_CY(ZTzUUF&YbNj zZr-tR`(U2D=Dx|^H)!|h>RCNIc-cvV?|t_6&0BYL-+Etr*FMMJ+h;dBEPDB9#rkbq zH>k^|ZQB?Kx_5T|*@|^*x6iIy`@;Js-CwHvt<}!^Ez)p_yBFSX8F{_lKKSw%PMFjD zXYwGg`HzY0GLMs2Y}mL-{kjKM?7ZJA-EEcjZD+sJ>hYbH@7%d_`Ga&l?cT2Lxn=E* z>o%+%zTrVSpSydVJ^pUJ@bFz<xcR0Xv*m0x8+wl|yZ>X_sNM?R^n$HB*6v)r{kdB< z-ZZ<yoVeopx%1k+bTDv!;7(na&6`&4)=RGLy=2Xrv+nJ;c2<9xT{qXew@@qA!g*(E zLDt@X=~kSjpR8LsVAaRYef{cgG!}tTh97YMDc^t6yT0zo6)U<m-e<Po_>TwokYKz% z?{bVcZ>h^BmQ7itA~r>nQybc*sGG9QZH`sWRcf0$)n!=}btv1A^mxui%2h~ZS;xAq zW7Wp2U#3)~vdMLwQVeyBIaMh)v8l>BSNd(0)w2n)ibYklrT!giyD<ho5Ml~r4p zg<cklP`4r0MWgYG*ao$$Rujlgku|4A?}$|uV$jn~N=;qFN-v3ZPGzcE4Vu~<+9HLb zYKpSZOKN=~!|M%tb*ZlkA@jdVA5>_LsnKtXoQk@P`rxK*QfyNlb8IzW&`UHwjg+)V zO%wH#(1u3SD(aeP)`jLAQd@;euPyY^`lB_{0%?ImtG~CcR<zY4O%-#ig~>(Kht$b4 zO<G7TMD2B~`N%SdCbuzEE$b25n3}Sw^lp7~4zbaU^=Q(E>;2liQlFV~Y+9{PC@ZZa zztWay$FjDp${Io6r6np0?Ov^=XbZlh&W$D<k`}e9%cKR@+ZwHf7(?9AYCffwxvIqs zTBfqnde%uZNa6!6R1<U2wx#B+e>brxVp#-MB5A+96WV(%vbIz#rADdA=zUt{qNubW z+JCW#7ETk<l54~=XlatBFUARcxb|O*Q)-8TI59OEyeX5|rLD>s)LBfb#jX9O#0<5B zp$>js6vMV+-z@%Yt3sQ`-WF9Qo)e=MO;d=;a;Ys6r|_woY{|~1QZH7kuC%b)Lh*W& zBeT%UqrSLg>ovbx->YTNH)icXBj&02!)Ijmj{)Y>$<krc&Nd+gmcG><F>SqClW25C z)Thxg(UH=k=*4U~Y!)gV8#Y<Yt}c<q&?akwV*jiy)MC~8WHut`4W&p6p%1O}x=?G! zHI_bBldJW=TFj-Di&`=r{@C!c$Vt>p8~V2ToqkZ1dSBEUz%rV$SgX~RNnU8_3hiB} zv>*}(G3gt$Cz+4X2`ROmVq%S>2bq|-DaBaB%sG@|J`I&a)>ah(p3IewjpmVZsh4J* zF?|z9rfs#2b*i)^;vP+2e5OaVo!YseW&t0<V3oE>JgCJIqw7f2fz8%=j#?ufvbNBs zw|s9Buj$-3+AIB3?-VEMWA!DWK>p}F#H7!yy=6fwFGdTnq~w}TNrubd96iw_t)=)` zyAXBUw74ZKDSm0P_^Q&JkV6tfS+gsvKuZg02_m)=M|IsLb+vzNSn@j89CN)wbJk+& zBO7Fhwn(Q*zd&e+t1CD{VoE1O^OA51I)9~pAkkVNro}YL@=1cRDqF9Kc2&|xTPvoO zxYsch1Jo_cFW!|1F7$eBg1$kYAACkC9b0XCqbWBMxVc2MNt$U!661PCYo&LI?V3sg zR+2;us72LIiq|yvtlzbgoVA$PQw(~!mau8yM)j5GZG2!0i97Yxc$Q5qr>)==bJA+< znFIvus)HeZ(E&q@<f3W$W>!3LV69IyH_5!3iB;$^SWw&{4J9ch7L>fJkmPNGiFKC6 z!`f-BkERs#lU6!S99SZ&LWIvGe$ZIfjp8OvO`HlBXg8Rjgn-^DB_|HlVbQ~dCayuH zeZ<@uB_!<_B~@CBoJP7WNge2b6qSyq7+qUdi-W2t5uslOx@xvs5q+sf<VOVxKu;zM zx2QGKoH<KTy|o&eQ>m|%?$Z})4*EE@Ufh#8dD?q4fH*}OL#vlqSJW2^(E2B6lPu0C zGD1c2R<ji^R-A%}L<+o+Rbbo2cv`27t}-)=S2FA!5v;N(ba?aweFqxG2dwVoyOy-T zLXZv-hl$(8;izI}SRyeQQJhpW6RmPxRY+6>upZS!3s_Lw0k22}YCl8eqpk(4ID>)F z3hW1|G_)QHNHShhK!R36Myrs}zurR01&jn89X%{jA=#DbA-$^+nY=bsYoITYfRIj0 z=tn85h;GrsWNDB}ORo1t1euskU#4TBcSdx!_DB*14Uf_**g(z6yDS~9A4kjzUMS8L zYiJX+;F61y!5TwiPamVhEuB(hN@=NeE{YO+LNC+~O7gZo=I9~~%~8r`BB^vOoK{Fe z385*eS+jF3Cqw$IM0AQRB!&vk3~Lfm;}N5wV#%>SN{);KhB!}>8%-6EPMVN*Q~w~p zIZfIdPJA-wq9es7I!}7NI89OzQ>Mg(k$BNwHTsO8<EyO~14^!FS@kWI7Fq03NNQ_> zWvmgQVlMS$H7pDp*rwLv>kD;qCG?9%CM@cy?lw)^iE)e6#wIJVBeGO!14kpE5LnvG z60;Cp6QvfVcLREhU&wx{;Y&0`!lV)(*6^@|m9{ZUi0T+%6-f7sNA&KhK*rXZpiB-- zH)-k;UN2b;eNAb*N$ekxpJFqajci?{YXui$;Br`)m3UEGkP)~sL=1BTxp<>ujr2Sw zl$Ze?#-_yD(*}#ZrTL{!CBQUgac72q6YGjb5;rs)G0jEiOjezJ0cpdC=+<}Y%TQio zUF4gdm2|^?i6~;26ZVl2E>_Uj>cCYfO%7OOX4ZuT?tm77(}mqGu^{;?=_ek*&es}< zPvLfp6I=~G7nX-7HEpeZ?u4XFikbrvI8GUt025#Agt-sj%ZfxAmtqI~R0a&@V`WoA z!chjSB%wBi+3K6LDKet0W&)<J4j0m2av`A&u`*B-;yN+34F?Hd_1A|;k7$c+qG{F= zM{4Uw2>Mo?koc+7)LI^-g(SSz4lyGJmZ2g8P%DEJ(RRwL7yo4zHex$z8a16Yex-$D z_e*wDYotY}km{1nS`Hm*BwFVt6fmv$$JUA#%F04oCE$?Mn0I_Irk!MBK+nUS(IP~g zS7VCmcak2du&T$*5&twy2QMbW3z|O$0y;&%lvS$_4YgNN+pfjcx67W%$U&>wgw(-5 z!SHGjS+HinMv*aEbp8=L8Tdy!L<YJn!y3~|jP7HBt*^5R7h9`aOqcu`TT;d)I;O#J z&#+D-p_Ac!9e0g@rRzf~<5Y~RqtjwVv=|Q=DJ!8^;ztIUI&##dt0mlIqv*U~TIjd9 zOf8aDMs<UiQDJ0azlndPj%~pp-~FMP!>0YyIgEI-@QBnzY1gN~WY(```r%(|%cPKS zoD+tBz?RZ+DG;9OfWkl`YY%0lOS$N^ScGCdyw;W{WPu`n3Ogqiwvqgg!iy=P%5leP z;dEAIXCz1gNA$Mj5^prSX{R+OeXSN>rl5|ict>I^p)sZM8@YoO(iH1QJS#RS(bl-P z94sAI*;ledq>gc?#4m}HTKj+&s3RNz@PS$jj6|!jU(5z2XGG(RKP95YhFS|9VpK5T zLW`d$RUrd}z0tOanZz7gJ*|yKFp8md&<nLI1s<uEy_1tLg%|_@g}Z_nC~&aEjnbwC zo}!*W$W&NhIvoWH14~wKkgbFDi=))yp6e7;iSsX|D~q>5yy~FB$c>E!t(csBO)ci` zSW3L=&|)T_9g+F9P0xUe2^NW1u>m9?AdDNlH(Br)pjgSts$awNikibKk49!DUZEva z#!%Hr;1GCE;=ls)8%tEeiPb{8N~^1x@ZKZpxP)O#@PYscA&G!brdjcOjBic61Vhl0 zH8>I+Oyfcof<!vDK<8jAN#b(uEA+P(6(<O8z{!vX)}lm95%mBmNT_|u4{->LUU9UL zgIWPSSfMa%=mPC%fiq0Z0p(<gS0j5B>_qE3a8-Tg^{qO#nQzu02{o=mz|OZmHxbtz zL<m0Up4U!R7(oexA#nsM^p5c&sTnP-<PYvdwu7mO<5|c^l!R_j*dS#I;Hm~Rs*wf& zQ(7@h9~}oVIA)+^wq+WM8oShjwZ+TRk&qC<>N8T(@GUwj_$uNad(HaH8gD1qo5m*8 z+yP}OtT}OfKsdL^Hk=^zMnK<Vxr^7twla)r8~9jk(!6xXjM4P;PEAawP-jQ{B8JCG z)IuAx0dB(r!9A6fXW#Jwvfhn~z@8AJO49h8N^xQva*#BCEm#dgqJ7k7>C{J7UTYqK zKr&Jk6BZ-0K%j{GWEM%{%LFP=(kL3MP4p{I@v(-WwEsF*C{Qu5Oo;+)E92d2>#z?q z{t}WGV>aQ*YSm>aYSQ?|SU3fq8q5RAB4?pRWz;rdD|4viSi~2M00NbCK+0I?fTud3 z=o45OV-}F80X>nR#pRLi!<-T4>Vr!*Q0EpGS$ocm^&ZK#(l&iCn8x`j`HT`?&@QtJ zn8=co+T#QoCJRQBuP~IQ_c^pE$OQH&2?&V5@kh&oBcZ$X6*|ipdl;OOEl3UC4JyZu zX$}Zky(E{0jF6=^d1}l7fDnu&Ualj7`j9mun_P~g&b*;c4t<GHD=}`9OY<qb4Xmm` z1c^~>d97x^YtjgMjtxi#i<yCrD2fB_s1bdEy%le2=_88@l!HQ+IB$R?B<a9sJM9Xr zVs^<!#U%f5##q1#Q!ufy5&$v+wEY#Zp>zrO1qPGxPkn8H^wFwW;Ynz4;KY!csf=Pg z40Y7DaeP4q^+!Kx@${ubwZ=F(1)c#mvfd;?4qzaGmw`G;vn(K;7KkGR5*W~QC3cC< zt2O`+1$(E3OQm+AKeGh1Xs~O<N$!D3D@B~J0)fi4{Bu}^4wH12et_kaJO2S|i0!U< z44^?HmdGMlS^pA)X<5+@e5W=l;xeLXO5mkXF-7^angr-{fwzO%lD&}{$$$uYBG~^0 z{^lQcLVVKL4&ymFx!Ac_Er9d3b@i$SmkIHTW<=D90r;^vphWUkbmW|~J#ek|IKd+l z9Sum6%q;+&3_pv<^lCAHg)^=Rh=YVWhO7QnfgfYL;K9|#dJ6*&m^?ZNQak`$`1aa7 z@n3_0(fLzfEEfz~PzHpD1g4ghpa!O@@d2I#H7JnVSVbi&3`f8~CFmK}5J<jW15hMp z)vWbfge4H7{c-Uw5D?223C~D&VfpGfVsoO{^sxnT4)MKqhRB6%UDQmAcEN0Dfs9b& zb{(;YSt$4$<jMX94g|21oFERBzQDjh#JB<MPK^y!u^Xn3P9gr7)}XZai1ifNnHEE` z^R#6%NNmWcM`k5>2lJr;caEG^eN%&ph6!Vf7(NG=DG551z^vfj71nveXe_akq-nIo zHF5+Tx&~m5glIHT@c{5%o>PcuA9M_!DCT%Zx?+WREl}zacPoI6RG0+~o>kj;6*<mC zjtbaYGnHh*C`>4x8VOY4I!j#PbUECBLtslTaR79ZBai_w3(y%ZyD?0yyST8xXTsSe z288X5SFKLQDhlF9NE_fh@el5ZjcEj|6s)WUja*`;i~BUHe9YS5I6Dy>*Qhl*mY_r# zt_rag;(9F_*oYqLNn4B~Z>+X5PR}_GXmT7zV3ZaW9PrKoB{U=8I&ghZmI$_}bCE$D zI%pqV7dciDQHD&-RunidmD$`nQir?5-o)OM)6l>`gjZzRVdd4@u7r&)35yX-a0g>l z@=gMw0tb>nDSf)7s>QvsfYFu(9ksrZFd%#Z@PJq%;zXdzs5`TSt<i=cQ!ODk4k6(e zge8X?KCK)&$Tmd4IZDjF1juVnWFPRaYvYhMjm7OX@E_`>LEn}5MA}<iIR?Tn<{V<T z)<AC+UK^->ix*U3)t3eX@pB8@Hq>5?KuMhgTo^|2Apo{PkObl|-K!!I4nR1^Kmt1< zAH)_5ZmXfYj0_H7ocbz&7rbPEXEeR0-!u*(vabbDe#E-QgTpA(S&G)mu`~uA5X2Q` z5U_V^R~{HkldcRWh*N+m3#M5Zk#_(`E7xM5z&Nd~#)7~ITmncWj|z8;kT0Q%h)5RO zwKxiyASdHs*JErEITO2R&;%x(@mlezV0r>FI`B0<8ZZFiSBxAY1({V6D<%xJ3fvwj zLkC-|T{@tKDAKxt5@%pVgSG`hof_W-qrbFXiygEsSxmSPUI7>r^MgBcNDCZRqP<17 zPyl<7z~qF14zxfFavKXz1dcFhP++QS)k?w$0S88sFC!Mg<bfYbbOjgz(V_y&vceBQ zT@%z0e<PA=Pzm%`#5+#GU_x*Z0ep}*N>+mpYk4tkDm<eC01SS~{tJe!J`MXuAEvP! z5yM$)abpp|6;TIdw7xY4+kzld$Yj7Ly*IKzr45CqgYH_(ZXg{AMg2TrDV6qLG2En2 z2*;;62!|L(2~R|V!(uNqH@wh-ugi|cy=FF*fjS9*fH?{13L?-Nx*^P1VfC^=Vs!(L zz$!&ya0KTy`^Bg!B2G9gq4R|ZI%pjtHmhL)y#?je+AAWYoQP);LKl}|1Z2`BlHp}= zOzm}RFh&dQSV~Dyyv6GVsOB`FggD74D$K{+#i$K%N5Vf2Hex~4xP|t)DuU<4eF+NT zum=Fh8Z6sd2RINLu|;CFm7#X5k<!RpO=K8kJ)>6%126%kAHk!#HWpGj+W`-g0HziS zo0tDp7z{1^RbXdmZ*Xlgkwwfhv<(RrHD)ay5<-g%0v!OoMhoF&4?^MMKh77PBBA)~ zI0OE13AButt9KKkBq|UI9hB@w%a@5qB@Z$mM&3#SXh38q;-5NGH6d0_v}_H!b_N&L zSjon6paWah8dHlnVj5Fx3+^5b^bsg%@FctO5Ezjt1dr++Ezx~V5(ga(B1wq7FCkE} z!UiA_IiT8bsf4&rx#3x&m~!y=7I7y~GS6#|D`PS>Ar5H~lvOMoT#H!VMDnXn{}Dw2 z91U2hl6hGDEr>s6If|k-Oo9>3RwDEqCm>is#2W+!v!D1rh6J`Wo<^AaAKroUI}kfg zH9$H624TLJ2Jyg}NCMK4Abg3bQIM6<nzJQ7z^GuT#@Yw#l;|0r6RL$2f(!x$5TT_e zeJBEX1=a<$lYmczOH=KDCDJ*eT@3u<=NtYbh8*nJU=4vOMa(_=hR!SoO^;TCT05ko z6cy2G5+aC8fcf#6*%>xi>jaX45(!H<2q_6gNFHcG=a`He!aFr+hRoSue~Y*%yM~F^ zqI+1E7KsqZD<Ujzb0(pk6B{JiR@*rvyoK1-?jUMmcdY%21d)nG!+OGchjH*q@Y1{J zsJ-8W%?w5)tB-?Ak`LmoMUG)?5wjsPBcV|7?U7zJE{Tqv{@=k78Ke~!2jL1(i-f6L zwoWx@I%^9MiNq*^^&}Kw7y?CBrJ)&+SIcA)RIu2HC?MW45hS2aCK4Uy2xJ+sCHlhJ zz!P?hrkRW-CdYLcUxNUh!Pw||kY0f1688~Pi-;Z897!%1o7g}EBH<Bi7qL?XJ69x` z;1KF4)Pzql;PBZ9sFGG-Z`Dx>+;+0jKvEN2iERjAB^9h4LRqv}92~z;SfAp<R2^nu zC*H|i4X$3`AQ2^OiI`(jVH4@o#Wb8s@HOPWHW@#I(2QkrYon=djEXr0512nCdwWhu z5T|2fM^11sw1q^q8>-0@+$)Szv6HwA8OsCx+LFN0lE;Ea0EXY7y91DR2_RSzc9u0L z0|4B?nPy-%hCD%lw7mgs=QybNsKuqgC1yPlg#~Vm_73r#oK45*_}}P1OkdldfaDGd z1@sdUJ5pdOPBn)TDTId}Q9Lb(V6>wfuy_oeV-69!!*)iPIC@-j0L6*gXABlHw20G1 z&Yu_uNDC`FkiLk8M6Q)}mGkYax4@~{J3w0ET*zi1K=nm;I;V&fE_5BqNq|hCk`b(- z#u!Yg3s5zdY&GeVEh@W$VOspiio-)LVIV#zBPS7ACQ}F-kJKNW2uF$m(|}pQ83<=1 ztP7_kB1wo*gE#>u5~GMn7c3jB%H;GsZFaKbW{e*5BO(1snj#ql*apkacsr_rT!-2z z4@9UOkmo=VASoSiAr4Vtry-pRA~c;NrXwDa>Er={?_%D`=C2)jW8$P>kxZDd;Vo~l z6?JS$tOJ}t=!2vo#mS-}(FZGvq)S{8a2m{fa?x<kNm)qFvLFgjd(pwPv7u6@TR=7{ zGOa+jOH>EG8_`uVJM<8kc7ryAr*J1bLCx7irv><ytPjo>;53jxB+&t29?Y`_zr~l8 zPHu=iXuIvQ5j{q0ITgt%NF)s=yqzfaw_<kY8%C{E21$RU(#VoQeCh%0cby3{91vGT zmX_p50@-3hf|CN;5*uy!8OM?MG5&Oeo^D8gDD1U^l$XY$0$B+7ml%>DyM#28^F_#F zz)c}&rirwuQu39G%DIvFeS~bmZUf+=L`6YTiNplHj~>>~oS92>080-^);N-@Ke$;^ ztp(ly8H9xLrSrgINS-s)sS}?KJ0rWnsL7Kgt-$8{oaaI6ASMxh8PFfm$<W2m%GPFJ zi^o_w?SkR4Ey#S7PC+?1-JvAn#9BB|0R)GoM+#Dl#iOH_IA&^y4RB{m62Ul&TJ-|8 zMCO$wPQ<50*&`;TD3DSlz|^GwR1Wi3g%hD{s5|?C%u}5^Vw(6Y0roW1WT>EW)<i)5 z67t0jCU$Ep%*v-bw0LoZpIU>+nI9qFH7iniZI=RT5?vuRvUb=Bvj(gqfM=kr#6p;6 z<ORze!6DN8WTUl}0ctEoTtN1MoGI)pWE|;c4S`Rx4p<m{4_t(2pIXCd1+I2-l!+)c zVouVEC>+uQbhB~xsL^$aa?OUYZwBZf4XiSHmTFHI>%DQr-Kl>hlh@>5VmOdjYM;1; zWm`fP<SVyM3&%19j?IJ>5P^W3SWW=2xGrQ&B#b4J+{HKgr^QkRH?i=Br_q9#+y&kT z>1E<}3%Uk4)yN#F4Gtn3y2&7OV7OpqV&>AYtC-uT-${G8`Gr$y$*c>xL%wAa;?VMS zS`F6CI$n&zuHsoa?he-GkE?)+^d$iCgdA&fp_vH2GDZv;*p5wN&w@CT>;*OlhK|8$ ze-TR$ONl6(9ToD-YNuTie$KTM2ApSGVL)I?6d<=K3IJPRLGrpJRkQPE>=4tJtd0g1 zL^6q9-Z)W-ls~D4+9{G6i8xY&Jqny*yu7ygladqZGNFFXqK{B;LL1f((H}mcaRwcE zeg;e1)a?*3AIJk~)h+HdaW#Y^NJW=UNQN|-Q7s5qgFlEhUSSJqk$n^hQW4H3!>cAE zuXbQwZ*Vpu%Z61drVXG8jyGllZkiBzmbD{9$U4n{wBE}5nUQ<BbTGnEj%4r+961|c z1jDQ;f<R|;t|Y5S=>SA0>7EFlOD|wo)KMMG;h>%*kCR|Qf=C^lfN!Bi!2%F^muf&D zqORr=fq{vV<zqugqhMFa*g}4YVf8tNFo_A^+cxa2tg+gutO%{zDjOp@1FusK!C3-R z!X+qNN#bBy#3gKP&QeiO0|r$<H$b!?i=>D}=OvO=St1BpW9)b)#{9tRL8QoPqi#cQ zB?QAEMKw|Ek&UNt;ITuoN+ZSwN#sQ*(F0zzEOgETYP>EDX@ts=2+&yPCPe=RK|<yL zs57QM?m8+1y_gK^m#AhS6j_AYsA#8{6oy3Bn6_6^m*XQ26K7Z^;i(kf8!!Qqx3k4H zi8L+T9`Oq>`iWZdO{A5P@8&?67NDrCms`G-7%MAe1Sg_*ad=2uBUqy!lS9KdkR96c zh2X5VgK<_tWm4?~ZI%WTAz|1y&Nn1SnrMNoCl|}G$_djz`%;l04)j5~8xBh*9F$3| zC>@H&LUVE%a8gV350k<<4SY*xBBj%Gl9R<?AJ8;!q=ObMwq8SG5$dI)x~KNUD==MK z>@KoM#F~inaSnj|9OojtErNzp-vMln-Ar6pnl8BhhBF(Sm%zEPP#}MZl(bkl|BH|e zxmAfc9|;&v$Cyi5Axy~EVHVW(j$nM&8KH=%#VZMTX5_))ezslAzM;a0@CT{4V7j~o z2rJl$lC@LX?Q?3Xw-DGAEv?nY_-~MIp))eT$r^`9v6ovS4wV-dQIZ^*X|aCzd}?6= z;B9RrA(jq^SdEg6K~)sGpz+`BFryN6eu*UEVT*?iZWcxsInWs+821Xvh#Lh&NdgwW zC1>7QcBnA0oRa#pXmuyuL=}mRj2bHp1dnVdzHiDK3<Wlg&qTx@IoIrFJwaQ_| z2_tlg9uganwngO>A@%~+2mW&$fMjh8q<}A*tw1ncb)?C6is&tN5tIVG*I@taTfowy zr<whcz$zr00(;rVH=f`ci-c)}rxlE(lC(e?IWc^q)g`ZUMUL3Vk#da+5&$qna+PIQ zWi*|zESL+)jAS?^!wg_B_{HR?lCwnGj-k`w98JT!;6JExs+34c?I202AApPqmHB*u z01=*dd{yECkBnNl##tZH6>ZkecB=}EKSI4^*Oz`fdxWaOhDz2spf=>F;D(bxMimfQ z6WJTlpyEq%*0N3=GOp85_#xT#4CrCf_#!$oVP><I*pIlg;Nk?4Y+Dij<51S*tdakj zZ59IW84Yqg1v3nVK*$PLk%LeZjI5C0L}Q#8NW6{62?ED4hv57={IJ3^0p298+(m10 z7aqZb#t$WNlMrYEo_CT>*%+sR1z8KC9p2B%CMgeNqZL@W03{iX9{^~nqv;aEqfZQ` z4Z)GxDT|;OE@}i(Vmz|?s3oi&vqR_F{4-SG#D|Po8>v-5x`4Aur#ferWE_7C7`1au z0Ygy#1@;y!Ev_QQ*${>-DA^)`9EgaFJmSc9VMuSp>%<k1gd%jW`7l#b8A%9Z$H<W; zD*$sCJxT&2zB3Lu7!vktgNsy>G(@cf(GD_;$?ihKkObrc6P5;hgw%1AnPXI~Q=5oi zwMbm13gqWB9F6G;g_g>_5<jB_{lz9nWIKQWenR|~^r4F41prWVw)hPf15}l$5TKT9 zBM=FPOTj@%^-tj7V6xH42Sm4990;*L$%-!6j0R>%l1KiD8^B}XToM8q1c2GOcU?K8 zgPT=wQ6Y6URk$~siIP8J929Gkipn-2)hT|%UE;7f_)Hoys6-&K8jsq6ipHD)_9iWY z`AI0Dak&kiZ&7s#4TM?)FCed{s$BkOxRP8S<T!~Y*<N*Yq>&g}>2MKVMeA&<gq?-t zML{S34k+457<I6L1bEeuWQ4gvVQU3Ij*$k`30$6Sx+9w$LnKB~QfP!AFI?1&8v(Pm zcx448O0~<CutEtJke7!-#xQE^%3@I?*a0QTxWc%y-;PrjT$)&-SfnR$(VR9xOqzI_ zE6oVMi!sT`EKBcIFscT?0z;4^;gVNkUW8jR(!oC@JAmXAXAP5|4KUPLB!d$<PmFjm zeRO&gbrbgH;4K0jAf+zq(AP3(McO1ON0@Sf(z1ra3bHvVfD%towLt+Sc&)V#ynvb1 zx(J9xgE5WM1Amd{kGKxWrLIovgdHialG)T{){wP9(p0ivB0Jfr3nheAm#K?vNtHD> z^=tAd;5sWM0tAIswZWRQi>VXxLmSs{b|e5vX%U$^u7hAza83ycf_p{gjjvWaBMD>0 z$zZMXjez$s3`nrAnI!xug+R_}>OxLNJ1CGWoPtdd1KWkn$*Sy1NUARLJ9Ncuft&<( zlXBPAiJjo&R8kujr7nm93Q`=&ttCkwY$kHFQT+JZb>(QEHlLt_M+PGI0q@Fw$aspt z5SS0dgsCP*wt)H+<evhi2Xbl2oowuVswoDbtdm%4m)xgyshq$`p_*P?xL8&n?9zA2 zl`?5Ms3?F<9}N=MGua-*zNj-Q?IV+d={$I_MM_GdORy5(NZ70(sUUZ;jMmv3fW<`D z0q==v+t#RXmVlgVD)~X|TI0}UA3Lcyl3qhZ)3y#K9{vD{Zl#OzoWN;tl=_Ym6prjH zn4VIY8f1>F4Jl#ga)8-@qu^gs83T^hMFJ%KIB0E`UWI~gUBU)TgR@>%T|F;4vmgwC z`PbTwW;KZU)DE!+Y#Rs1i1V={<iOz=0O_G<lUb;7$l1mUOVE)1o1MVSA>nL;U&;1x zX(_Q378}Si0Q5wc2Fqf0<q}c$$~!{}Qh`dBRw0?6pajMw_X&`@gziGLva?tb1kOOK zvg@)~H}WqEU^xn+Fq(4dbovq)nex^Ky_~$SE=kN3ch<JZN?<!DFh<8_oJnMS8MXka z<T3*%js=66NK3Mo8`pqf3^_^NbuCWe2jFpdn#4(hT|VVq<hl0ugF=#A4^Ufmc)g3z zNreGzrbfbv&V)?~JMa^NSBO?4Hi7i6Of@fX2heE)EKHgw&}z*+0=&nbrL(_Dat6F1 zFNJ&-oIiY3@*zRBsm;UNAl_i80=vao2C^~9l5zPYW#Xi`0i00?W4jad2?GJCOa2K# z3-|&PCHVdZybs_>TaR{3YN~n*7f@12QNud~r(1-r)8ry<dY(fO2@E-vp8?DqPQOPD zkWwP{EU_V}9&mt_ut({_Cis%WL0~r$B_cHjca5r#E}p_VH-;FrT$H0yc83d)@w!|d z3mBqfYb2|5YHmqDjJ)VX0Gk>XY_YD40^i=XPc}73OktrNPaqya!WoXbc8YXNPG?O1 zSoAWHJ=|JMUrsElw5wlD4tf)cXy8Pgs^kDj;RKcBnuK5&r6q?Q_roa<xtR<7QMzVb z;CoOi&KUKf7(rxZ$lxXsiHL2>siD4!AQp&^PZ9?dDNc?z8F7^Fq64ry0U2uF4Ny1* z-^t`;3^ayS5&fktN8f7UG-yIFNILim#ZBIJ#z>?R0d$S~IjHDBSz_~}r1^Bxo`bC{ z3f0NTDY}3)7pvHWVzqqX1|^|gYB6p#TS{_)VRX`dB>EcT(TKM;8^Xiq<zQ0<>HIiK z*vm|sh;MTN6{QXlP_J}myGsnwrqpI|`Z>0RT^1@Ih?i0qVc|mxBG3@=PogvkJ0jJf zVVL2*IRn*e*B~LY(Tik0SkM9DxBwx6dXbXH;UnMCwY~&Y407X|5!b_&C4~!kk$E}o zCiy}Jr&HkMa^Z+sw=G<BN35P$AKt0io9bQtl?YR`M^|uD26{f>lQhOJvH@$r6q_+9 z@}{fb#9ffkCt8G7H8jfQ4pgSQtQx&VMl@a(^0#nqfp4MVZiV1tc#HtD3P{NyfC5lK zesKi$CZ8iZS6j{ovBeVAMpb|`Fn9fwcBHb`F0q+~)2qn{#H*^JflL%&>@G7Y+%r35 zYOgkfzZfkcX9k1-&ww2OSt+t_L?J6Xy3mBXVklq1j0>gnt(|_3`;GSJZw31driVj~ z&xS`#{zZ$M2dvHuL7>UiqvA0*ryZq>F2#h4z`SIGQku+_5J0d7OgU#%ibeaH>;{=h zEzDdKm!*CHSGlx8#gO7&1D4ED9cnoXd;um&1rBGh&AuI}G+2U@0w1VnMFKw7XIJNk zE9o4z?BZCbZW1gbalJ(;kv&1oqH_K;x&vd>wFP)-m|f)la(<l4M>;c30U1f8SvkRl zyhalHC_%#UD~!Q#HjROk)#~IqG6UKUIi*~gudw~goSYHpT81KY1#Wd$Z$&Cq0cMT` z#;q+b<-z*l4^=%BB$8u57Du9N5~n*_uy=JB4Og{LuLq80M3`!2XHsKMxNHGO3eeM@ z3VDL)nM_cP3SmGm!YjeB1c(aPJ)zjS831Pne2~~9`Ee9RB}2i)qw#@jYkX!vjxD*( z1QDF(!Z`>2t_&9wam5xS=w=7Smu!$bg;5O*pbgNW&YV90C2GE-b(F79$qtg^oRNj? zVo{1lQkR5E(7_b|$(v491_=d7fZ+Nr@)tlDjr9|8wTT#A>;xYqA`Rrz;FuBImAG)Z z19#b=>M)%<@48|xwr6y@d@F~q@gYV+fn9PE4;Fdhf-rKFIbbA{fmGJcJRq<pC6ANu zSR_^dKsL-CAp?wvv^E+{(G`FfksahGm8`IF@;wa{qBky6MC+AZeJ=4y)`_X}SPm{H z18_sgkS$CEI<lUm<4`h2?GY(})K#Ia@K>}wBto;w4j09)0F5|NS#}9azAJ+O9yWtc zGu7$FvPpVn_<}P{QA$k_niGv$L)w9$DO1iynyJ9T=*JoW;-@Yq_=b(_GvufuxLS7^ z5ef)SBT!D@5MTi{hKD1@XhF>YpUAc-olAwi$)<8-(W^+n##n|?U1w>K?8XjbYEv!B zfvg=52_*gM7*o~HoimN^62i=P-j6*Q5MfYT*viOh;FcdfK~70@ii=Z8?dHMlSdV2_ zn=Gjn(IgZWW6puK5D+gcPaQmNeOW_k6AHVUa0?k-Y-NiDO9(7Gca%d5uu0xc<*;$% zOW|Vl)d39*K^_-{4#}BHWWZKs=Q~83{IE~aU0dRsIkZv$i^P3*vY%0gh*hBJQNZQu z6@U~YeT1o7C(l~kbXx+bgEs-HjMC@iR9z4zIosJ<mV`z?z1C4I5Kj{B3`}s{1=m?| z(N67zM_g`K9Fz`<p|Wazh@ZkWM<kDuoK9{iK4Q%sDY0>tXN5E9I+q66k)SVOG@>L< zDgs6%<$#Ls#uo~Z?uq(m>VzvfzSOeTV9R96JFe9D#wk{Wq-++pc4jgWvg|ZBF0pGJ z^ud9x95KS@lhA3Lg6eW^$G8zM=yd`C2F4MFzWt7?bO5}l8)$s91U4qV0L5Stq?ar; z6hC-AwGa4;0JlWJiqsjBf%0+Rlt^Y!vdBV(wxD5iWop<U6pA~Kk;04CS3lIgvLm}l z)}?2q?e)qvdE9N$fMOA9v^*l89P6yHgNFfvSmS;?r@a$S#?kYIElyJ_0Us#m503W0 z@xi4m1=gT%t09M!=mAz;rg(%4S-PYq6pvQQ7rb@6%>6L1G?fE{d5k>+6j9Vm0te;^ z$U32CG*$v};7FjPuvAdWzMz0Y9O}x5ZRR<XqXyfHc8gph2f~7X81Px~yGV7x#?8@{ zuw2E*2E)0XCJdboO1cUr4)rqF7U09A&LiF`j&kMtUXmZX<UgG_*W<UoIL%iS)~?O- zwKK`VqJ|(A`NF&n2?l3XEDW+8>q@p1ITZnzt3<yC#G*k<oLXE3mawMa5M-UwjOhIH zF1fRI>8$NvyeFA55sQgDB`PFBS9fTrrMrrSoM><?_QSdKu4Z<{a79{j31nMDn+IU& zczfJI<Z2+Ue*`u&L$|(I#J3pn;eexfe$G|F!R6XM%nB^)++}C6s~ED5Y*FP5oQt*W zyd>9=qHs|?$+-&!X#+sgzUnF0jyGbQka!e)&mN8dYX#H|c<5_B2!^m3WXZZrtjjNK z4HenBjR+VnBqPJs0nNraM|R#xwd-zs;$){THNxrXuDJ6)a$~6Gf^#MDhC+?bo3t^= zA!uA-QW}s2g`qG90m>th%R2}g*hZyRAG4E;Tjxm!1CP`aL<f|JrnZjZvKYx3;E|%M z?7K8UN=Z;>5lQFDUH%=uD6wK(Be1>hr%V#R124dr9I%1D6(kta;Wp0Nku6MiLYfhb zqxBTY6Xv!JHpEE`Ez61BjV|gCV#+t24R6HOa<;OPDp4aOjb#GQjye;ZCG`b;OtuBk zGjTbBhnNCR_Hs5G?p#7}aWyCR!r;DVpGMe(A{Q{INM&nV*mtkJw_Y4BcA}<(doREz zNleL&aZ{im={?_3=bCX;7`708Jkuh5+mSEAx-O$=eX$NDEdWZ`8C=wg%|s<B*CvsA zQ*+q@wSqBp&<+<BI8`7z!HP0X->(54O_>kT2&yHByRpt>-%z4FSEBE$P<_#;v*f6P zBizL$Hw3@{A7P8q1u2|ua5Ox?29*dlim>D6%V67|bOqAt$l}S)gzoT0Oc6?D8^<Y( z=##!t*k8xcay@hDdqF8><~x1YXzU<jxD<Swv|G{=Vs{0Ruk!PCTglg<w$6g${y&67 z+vON~v!YYXsqDsXX5sJ}l7VXKG#bEv%DT8u6IY@voR);d;3gw-t9&~l;6dvEHfSZ8 zB?w|K5^<VHK0a<1#vG@Eth3s=m*`gxEq95LZV*AL2=4i2KFq4%d>+(3APR{j(RGP% zn(sCAwGO4zXNmh&PXCLpp#;cBp}Ibbiv-94Z_zpA#6^2ipk=O;uYKPO`%Bgi=m6TK z?NU2^*;HZY2z%17Fqi-M&Pf8+B%FW<iJ3~*r)8%^;IQGoxR@7Z%#}8FKkQ8sV@%v> zKspmk-~{{v7RNTpzFCWJuL`@%SSj5-XUSQg-0jxblfxHrC>r;WXcxuvuu{c!Sf$Gx zt+X(-$s`Mg)Vb`i1?eWJSNgs-ZbY`JPVp(ILu7%1Z%s=^x63XUjM9SIvWL)!14?!m zxVREbfO4DG)zD@31-i!El07aj0Ed(SD@IW1t0CZ`*4luIlr|ah1dsB4la13xya|zm z>dVPUW@wxMi&Y=GN@;?2+*J+WSoq9F-%G&NcNF>iQYbDC^wI9_9W>fX<{c5#)ZKcT zTm(#QZjQd$3J-@L0y~gkRAbBN%jki^#m?Z8p=gW%3!5Y#&Im{kaZ@r~Dg%N5zm=^j z?$^Y(L2$Cpl*x0$0|~TfKcq0n2gBb-n1Vs1G{up%)1|mpj=SXe(vpC99euk81`!u} zV|su|`!<>GHXraj(#p8RuW;2V7nk8I5ijzkFV4_*m5^_*;<$j+IV~LD4IB&HwQ{{l z?HW;1WU~R3<UA~3LGFR1umyC5KxO5hQ0R;BZM%v=90BqV0fq_Kb!FJ#-E4JodM6Gl zO5Bk)Upm~y>5$;mA|f+VSDl!AaY^ICDk_qxuC`x+nE~|gNJHrgMt~XuXk;Dv?nc5Z zrAr<ud?L%PGU|z2?0N|dPTzonmqcYTmH1t)N8@rO#0<kZa*3r=IZL&0vH+gD3-v14 zyK$V3i!`#;4f$Qz^u*dpOCl2<B$!Y_@J*jo16RJWgWzCytr^e@`KoYB_AS!B2-Khl z<{P@V;kq<iZis{AyNSAdd?MtD)O!#j%9IGfU@ZfnST}T~U?74hMHfy-Y^Ll@D_nBW z*!nCimV9j>unYGZp*FZ213RtoC02kp1m6MT9H0bmNUif(jLhPM<G|P@!=Yh<zD&w@ zkQm~y@M=0QoEz=&$njAqj)Si;W)pD(TTG+}VZ2GIVoSG<QWDk3HoLMD!KnmpeL)g- zg1tEIz$AV`RxMT(t3)|#c5+zjazFGhi-f&TSzqJ4Ywr81xHp?<2+^9xSwTz(g>L7z z=@Nadx=9HxyQ>Sh*TF@hn4wa7*sFxMNn9W?mfO&9NvIYgE!THTAg=JJi;gu3=D7?3 zkGA0=Y|1>GVgv?W`<_QaLBw$?z6cD)=a`_8vn)WL%T8^UzP!y)O7Pve+zL-189_n} zl8hObNBBy6KtX^FUjyv|P<#XoV(w7j*bq<kwUCXk76BbBZ9@B1TqHp715*KeiZV*7 z_6Q~taVC+@Dd7N?z^5)=qKulekh@wwQX*_Ck-$rQ89m8uYQ+B?hesY!%uv~MC!oNY zu8rK25X~*hC71*zs||1N!Q_So=GO(P5rV$lq3V*GsTL0|esFvw8&2<lGveG%Kp~Ng z>*To9(;AmtZcY&P6rpRjmlUzWH-k8Yz<;2@x8b`4J$1LSw!TRPh3$Kca^0mJIDU{_ z#7Qn&1)7C@=cME8>qfil%Si~sD5+gi26XFs5l&)o6%hVD%DV7>vSCh+I@^Te66z$d zN3nKm|92OHFH<4yjXTjPgkxXvdz_7kwL?A<+K)`l=&K?~StGg{2~WaE#FL0*JEz6* zbC*Gp>+Div-)ZFw&g}ycJ8jXQI3e7rt2uNP*2(ZTs=dK<=&EMxPMA`o=t~y3fu(lB zGbSG=nfpu{ut)G<YE%7G_El3xXPgQ~COu#sDhnqP?8NuyYJItLogzb=aC}orWclK{ zyLq|d3MFh#^6|`n+BRQzM%V)91=|D%fD3*I`vY==P>@?lhAfvnQlwD%Ld}923hMMx zF2VLI^<(U94G2J1C-z9~91LIm<6BsLqYY=Cy}>3Xt)7o)T$9(38;^JAs~#!Z0b?go z)=(n8HYR^`CMowW7t=q}Khr<cKhr<cKhr<|pa0qAzgKqsnHx4gZ+64l9cx!_+O}=Y z@@H<`vSr)y+07f)EZ5(cpLOQC=kD0CZL5E<ZpYSg`B^t^JoB{fhy7nxyZ-Vtz4@&B z2HR_9!+U2&qu&?(iRdpye<%8q=-Z+ni<T}LjSdnWB|2GDiPnfN5?v{}PPAFHL-Z2S zt3+=Qy;bx(qW6nFBKm~r)1rSAeN*&9(c;CU(E*~vMJMoI(iEL8I$!ie(KVt?bN@Zg z|0H^a=yjrB5#26&kLbgqkBdGf`uyB~k@H_fqdi8WeMN_gjuV|C%A#{bj~6{vv|hAT z^a9b(i*6IWMfB^UcZ=>2eN=R}=rf|Ph`uZOiD)nW%blWQL@Py6bhhXc(UV2b5dDnk zd7_&|w}{>-db{Xdq7RDxSag@@Z$)1eeT#R_EInvu$z!)~U;BcYnR{EymMt62>@%8K zKbqNhX68prym@M^UaJ3}aq}587rFU*nv321=u-ce?P&hnQgav0Q?&gvOWnMl=ALf8 zj^<u&{wdA9-TWcVecW8N7o)m)9nJmRd@arW-TV`p2e|nIn#<gL^xkS7=;qUD9^~e0 zXg<QtKc@LeH~*F9!EUbHN6karyq4ynZr(=oQEvVb&BNUM7n+B=xnf^6k8txEnn${M zE6t<a{0PmX-TXeyW86G>KQ)ha^Jz3^-F!98<J|o3G?%;iJ(|b6dD8xBp5W%yG*5K% z7Mdryc_+=2-TW@i6>gq*fSN1ad@9XHyZK8rSGoCNny0w=9h$4%JYkudr@HwRny0z> zDw>6xe@L@*^V>8lH;+G1&EV!$G^3lpNV9hH4`?PgzeO{<x%?nC8#kX!vvu>8G*5T) z4w`4U`Oh@Zbo01JsJX_?C(%61%~#Mo+s)sn`4~69N%OI8&OTDjbKJa==DBXZoaT9M zeu(DzZhnL21#TXDu$mXTc?Hdj-24Ta7rXgEnwPlwb()vDdCVbdKF-a{X+GY~pQrf* zH$Oo0GB>|Q^NDUAeW;q3yZJ<#SGf6eG_Q2?{WPEC=2vMx+0COKrRG&`UPkjNZoZ7> zQ{8+Y&8yw~Cz?-l^T@;0yvEHZ(7e{on`u7X&G*v0&dsmTyxz?t4p;LTZa$voS~p)x za~&do$$QlNkm!@5e-`a~#GKe!dfB>XZCt-&X3>4k0}njVT^_AR3elyaO`@OgcUe5> z^1FKEy`sMqeND92k-aW^47!}GM^=k260H~A-0!kv(B-Xq<Tpeg5q(DVqkfmAgD%G% zB~2zeNAz^ji;n7b*>lk4EqdgwqB}(Qh`!(Nve%%?p+`$+in8bm(X)^4b=iB+<u*O? z2GP4ke<Av6zso*@E_)p#4JukGI#0Cjm|mBC2VHK~Bd-v>UG#^dzwdY1Z_wrc=#eGI zjz+VhGelP(+v~Fbpvz7@@?z1OMeh~;b-&92gD&6EBR>!wG%GF;T{_$AvTV@hXY|N( zM7M};7k#wf<-p-6dgKS9M;tdAoho|ValI}F4M))<&k@}sx?S|qewRlKx_nKKd|R~d za`Bqz{N=qaj~sN_phuo1`UTP3M0fVP96adqc|Gza(dc;bn&|Z7dtDA0bh%oOTrYZo z=nbOx^t&87=<-QD^0%Vziw-<Nt9C-K%cBNeo~B2hA$pPMjiUGUyBs#?@@YNtS<w$g z2cIZA^Tb}4!v|fi(j(W3o-ca6==b_vju>?LD?M_L=sTkQPa2I@oz&}c<e<ytdgLjh z?V?*n@9cLuYS85`^vK<!uZ#9Pc{Dol<X)Gf2VKtBBbSOciC!jpYro4e!%_6e-J)-Z z_F6F-owTCY<=8=&i}lE5qGyR-E_z45%j}@b$MncuqOXdUtdyO;ve)IfL6>v&$i<@d zqL+w%wclm=pv#B#$e)NlFZ!|Qh)4Ij96#uCx*mCq=o-=UMZetda>Ag?`}D{iqI*Q& z6&<vy*X6`Pms*dUA-YPmUG&<1my-rv-mOR8FS=XwP0@a*^tzlp=u+sBB)VL5qv)1? zmlcC9zoSQfPxJ}VKZ*8S-RrV)(52ENjp$0zHqov9E{`5`d6yn}kLWJZ*F<}t+Uv4v z&}FqA38E*6o+bLlewR}QU2fMSzbpE<=u4tKPV049J?L_p9;ro76m1dxQoqZogD$_V zN8T;^bJ3SYONw5X(*|8m)FZ1z7l_u0Ztiy}23>wrkGxCtG0_)Ai_2b@a?oYD9$6te zS9HDT#r-bTpv!OQk#~yzO!NiOqN>*=49y-ra<b?g(RHGq?RSZTF7MDIzb*Px(Labr zq1UAzbU9X!oG3b5bdBhR{Vr)}T<MXwitZ47TJ*2|E_u-9kT@D0DN3R%M9+!6F3q6J z>-5N*MDG#(rRbmgUD`pH{cAlUI#qOuXmj1`a{8dlEA_~&qTdqzspyOSE@uq7EKWLB zq7y`q5nZ2pUCtbId6^!0rRdj0cZxpO@3Lml<tKV%aUPA15uGl&I`_JqH8kP$$csg9 z7QIjOseYHU2VMR}kNjA4Xd?wKy1eOidCZ{8v-QaHM6VUSOZ16;m&Xped|i)xN3>t7 zb0fO2?R7b4Xu|1{=ZJ0*-7fmGewT9xUB0YGz9HK4blF#;b58GdId9Nqtsc2S^fJ+} zivF<Q<@`aHf6yae5iL4Hdm~zNMz6~SgD%(Vk#(Y<6}?&X!G4zuhsKp2`K;)NqJz)W zIX<)3<)T5CEA+@yMK_6V6a8+#%f*8(O;meSl4%;R+|}c8h1u9u%Y;4aOqa=|i%Dw0 zD7LKI7}IIW+7X+EEE`Kl1&RByGB&l?*5<IO$-tD%jMvh<0m_JhjgCMz<2A6z{Jez- z3ZcNh>KxDh^PcB>-rxJXeCK^1UNzAzg;<i*bZW-0w$|jm(A;Hg_Jg!a=(xl<NpGR1 z{TsS1i$DG6T~UX}-&CatHU9n^vDpvPu0jtao+0y`BUXt2H53)dIT{hoiilpAP7!Vc zL+t^v7ePjYN4d)tF7$6@|6MS$!x^J*FMu&VuI)znkR`|{vh96+{h_9LSu!qywRXpC z11Z9t*S&8b6C~Y-Fa;SC^p@<j1?aZD@NEF+Sc5T25l-4nJ@tV254|Z~`zM9OIQEqA zL`pR5aPHFw#uxU^&|1LjeIJ`$0LAH<`few=9Has>u~dTJ$T?yw<_e{-)-5zcT0?Tf z->8q%#u<w6BzUX*s9>o8@{*7W+J?<@4Y5L1ukgR`J(g@M%q=rcWiMZ(`L30L_%-yI zE4&|YF!PoYjs}o-3~^&?yZd~|DV0RSc4wwU7H^!Uw`Ay2+x^D!3&D5~z*;*}gi~Ph z>O*T0;1*=*@$<5S6kV#e@b$!v6aVT(RJVWEpE~o2V)AxU0XLB<g>qcsQ`aYt3&Pq? zvO=TD)cGfh@F_lM$WPj~>RE?G)AYf*bfL@tHM(zKA<X;5>1<uktNG!^W`*WEdnvZ@ zqM_B2$9qg2u1LgO8nGzblOIurwHHU2X5&Yd8rb3KGbtum^xNoJZg6DAv%(X`=3Ljp zrQ$br9`?A-Jh12(Oz=YOHs&pcpeBDnmztHXTQZou>4d8yWLPBQYVP}Pi8T7!VsOtt zz_Z)D>@k1}`B}fAIqTT~QA?lZYWPmQriVVt)fkl0Bbyxq?_eWl$0zNVbALlWODx4? z41U#jUr#DAL#|s2ZA#RI(c<x#ui7b@qntOjSnn&${=B53kjwh%&U+~lW-$tz3%P`+ z>lllPG3QXy{(G(L^&4m%VRIXzTuO#ur0D$onAX_HQFX%cRD(+NSPADnmlJWUgW9j3 zY`D{PO^jNcy;tv!9iWZoAbWEnxsX*2<0$8LVrq<yG*t$&A!{1P-JDdEG+JL@+&?<X zfOCH#nW{qem|xbCM^D9M8$$7%=`L0XZ)o8r=Hdur2>b}V+4mybab)DxL$6Hc0n&&= zEQ*S)$4=ZWZ8E>j3ziP5wXa$z=O3QU6>rN}g3#<{(#XKeKn3**MgCsflzoWyx>O^O zf20n^FK82kSdYG(@qB65xbuB?;w<&T9u_1NpqLj<Ref0abFtb;H<*l%bR=V@fzZzE zkk$^#X?@=#=&nCnk)C-!myOuVf;<PgkV{4~yRlhT&4DUJg{3jSMww+rI%kR_c~e8x z#TZ^uU-X%!;XvmE$DCv5yQ>pQ&8r8d7$lPm{%y%bw~9=3D^)+7Qwv;T3&niA{6zJ} z#AG|?4fd)a?2c9KyJ#VJ^bWCoN8vF&MrL`(?_t42C!uk{Rev?yg;&EBP4>2dn*@w^ zY1!_47E(=UqE2^-xF_K+91lIYVsZHs;K>Ydm%G(B*7M!#WO&E<z@MgAAcS@o^{KtY zt`nVxbSy0hwVw-paP6O4<7O#w>4@u|XK{8`nFb_9qp5n0m}26)f4UZ$YZ^L_?)(oD z@8}O`eQo;uiiN=Ah!5kA+_;5u1|zD*cco`0H=UV@`=-TW;?c#G+~;z>+Ypz;`FK06 zLuVA#O=1+IYT9sP*zW{e@NU6YwzD(H=nH&m{9eo=#<8|`G*zX!_UX1ixQcy)xhi$_ zkTt<1+H1B13bdczmA|Y67^Gi_^Em^qINPB^FlHJ+MP1U#HmOkK#R3$sJ->ztk}aaC z5I2Hp=i@%_(D`K*I0I}oq3B@zTuOZoFW`$Xf#}C?x3U+n6pdL3sK~rQIyxl1>}fQ2 zi4wr<)!eNz@o~8zfKJXYzgIUYlO9v2?k+-k?&p_V_q?McuHzVDg5Yp@5Z+e6KiX-7 zdul>!mw12qLaqIVec(`!LtJSgm@jc!nKKK)0UO6Q;q&(ee3+_!R{@A~#D4f*ObFgq zA}YAEDNu#PyIcIQlO}ebg&=Cui8U)I9uTl5YT%q7Roh3M<GlXc=(318n_4<?lhhY1 zs=(k9Gub5uM})$1fobZiA%o65@$On<4VgQ$S7G_SKNW!1djEfVqAeWoIVWiVa20kC z(6w#CnS9C(4x7@8l*wi)^Q0IYwm}cpRmlbx3b(4dM(9ldNZ`h{dyfG$eS(<FY+UCW z04QSP_wQ3!CSv)3IwAvF&4Emt1qJ-l@~72cUan~?owL|w?O8EU{h6}73vYM{d?MK^ z$RHlz_wvWC+92#dwQRA=0RY^gzn)u3vb-1ThX*Ti*_`u&U-R#QLEd`G*e~m-KI_;0 E4-Uu~O8@`> From 239cf2966e9c02888eac8b28dd342c77171f8990 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 13:56:51 +0100 Subject: [PATCH 071/109] fix opening urls #134 The problem was that LIPS tried to send http request while opening local file The problem was string::match that was returning true value that was null --- dist/std.min.scm | 4 ++-- dist/std.scm | 14 +++++++------- lib/bootstrap.scm | 14 +++++++------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index c04c605e..e74d8f7c 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -274,7 +274,7 @@ throw exception that function is not yet implemented." (quasiquote (new lips.Env + |_| + /_/ \\_\\ + |_| + + |_| |_| + + + \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define (environment? obj) "(environment? obj) -Function check if object is LIPS environment." (instanceof lips.Environment obj))(define %read-file (let ((readFile #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) +Function check if object is LIPS environment." (instanceof lips.Environment obj))(define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) Read file from url or file system. If binary is false it will return string that contain all the content. For HTTP requests, If binary @@ -283,7 +283,7 @@ it will return Buffer object. When reading from file system in both cases it will return Buffer objects. The code that use those function, in binary mode, need to check -if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not readFile) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (path binary) (let ((buff (_readFile path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (readFile path binary))) ((--> path (match #/^https?:\/\//)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path)))))))(define %read-binary-file (curry %read-file #t))(define %read-text-file (curry %read-file #f))(define (response->content binary res) "(response->text binary res) +if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path)))))))(define %read-binary-file (curry %read-file #t))(define %read-text-file (curry %read-file #f))(define (response->content binary res) "(response->text binary res) Function read all text from Node.js HTTP response object. If binary argument is true it will return Buffer object that can be converted to u8vector. diff --git a/dist/std.scm b/dist/std.scm index 7fffee52..5185beb9 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1245,7 +1245,7 @@ ;; ----------------------------------------------------------------------------- (define %read-file - (let ((readFile #f) (fetch-url #f)) + (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) @@ -1257,13 +1257,13 @@ The code that use those function, in binary mode, need to check if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." - (if (not readFile) + (if (not read-file) (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (path binary) - (let ((buff (_readFile path))) + (let ((*read-file* (promisify fs.readFile))) + (set! read-file (lambda (path binary) + (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) @@ -1282,8 +1282,8 @@ (throw (new Error (string-append "file " path " don't exists"))) - (readFile path binary))) - ((--> path (match #/^https?:\/\//)) + (read-file path binary))) + ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 66c0ccff..d4156434 100644 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1245,7 +1245,7 @@ ;; ----------------------------------------------------------------------------- (define %read-file - (let ((readFile #f) (fetch-url #f)) + (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) @@ -1257,13 +1257,13 @@ The code that use those function, in binary mode, need to check if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." - (if (not readFile) + (if (not read-file) (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) - (let ((_readFile (promisify fs.readFile))) - (set! readFile (lambda (path binary) - (let ((buff (_readFile path))) + (let ((*read-file* (promisify fs.readFile))) + (set! read-file (lambda (path binary) + (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) @@ -1282,8 +1282,8 @@ (throw (new Error (string-append "file " path " don't exists"))) - (readFile path binary))) - ((--> path (match #/^https?:\/\//)) + (read-file path binary))) + ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) From 080a85c8def3f317e9cfa147c7aa8847acf069d9 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 16:33:56 +0100 Subject: [PATCH 072/109] fix minification script #135 --- dist/std.min.scm | 1144 +++++++++++++------------------------------- scripts/minify.scm | 18 +- 2 files changed, 354 insertions(+), 808 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index e74d8f7c..5d7535ce 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -1,802 +1,342 @@ -(define (%doc string fn) (typecheck "%doc" fn "function") (typecheck "%doc" string "string") (set-obj! fn (quote __doc__) (--> string (replace #/^ +/gm ""))) fn)(define-macro (let-syntax vars . body) "(let-syntax ((name fn)) body) - - Macro works like combination of let and define-syntax. It creaates - local macros and evaluate body in context of those macros. - The macro to letrec-syntax is like letrec is to let." (quasiquote (let (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "let-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body))))(define-macro (letrec-syntax vars . body) "(letrec-syntax ((name fn)) body) - - Macro works like combination of letrec and define-syntax. It creaates - local macros and evaluate body in context of those macros." (quasiquote (letrec (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "letrec-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body))))(define-macro (define-syntax name expr . rest) "(define-syntax name expression [__doc__]) - -Macro define new hygienic macro using syntax-rules with optional documentation" (let ((expr-name (gensym "expr-name"))) (quasiquote (define (unquote name) (let (((unquote expr-name) (unquote expr))) (typecheck "define-syntax" (unquote expr-name) "syntax") (unquote expr-name)) (unquote-splicing rest)))))(define (quoted-symbol? x) "(quoted-symbol? code) - -Helper function that test if value is quoted symbol. To be used in macros -that pass literal code that is transformed by parser. - -usage: - - (define-macro (test x) - (if (quoted-symbol? x) - `',(cadr x))) - - (list 'hello (test 'world))" (and (pair? x) (eq? (car x) (quote quote)) (symbol? (cadr x)) (null? (cddr x))))(define-macro (--> expr . code) "Helper macro that simplify calling methods on objects. It work with chaining - -usage: (--> ($ \"body\") - (css \"color\" \"red\") - (on \"click\" (lambda () (display \"click\")))) - - (--> document (querySelectorAll \"div\")) - (--> (fetch \"https://jcubic.pl\") - (text) - (match #/<title>([^<]+)<\\/title>/) - 1) - (--> document - (querySelectorAll \".cmd-prompt\") - 0 - \"innerText\") - (--> document.body - (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) (quasiquote (let* (((unquote obj) (unquote expr))) (unquote-splicing (map (lambda (code) (let ((value (gensym "value"))) (quasiquote (let* (((unquote value) (unquote (let ((name (cond ((quoted-symbol? code) (symbol->string (cadr code))) ((pair? code) (symbol->string (car code))) (#t code)))) (if (string? name) (quasiquote (. (unquote obj) (unquote-splicing (split "." name)))) (quasiquote (. (unquote obj) (unquote name)))))))) (unquote (if (and (pair? code) (not (quoted-symbol? code))) (quasiquote (set! (unquote obj) ((unquote value) (unquote-splicing (cdr code))))) (quasiquote (set! (unquote obj) (unquote value))))))))) code)) (unquote obj)))))(define-macro (define-global first . rest) "(define-global var value) -(define-global (name . args) body) - -Macro that define functions or variables in global context, so they can be used -inside let and get let variables in closure, Useful for universal macros." (if (pair? first) (let ((name (car first))) (quasiquote (--> lips.env (set (unquote (symbol->string name)) (lambda (unquote (cdr first)) (unquote-splicing rest)))))) (quasiquote (--> lips.env (set (unquote (symbol->string first)) (unquote (car rest)))))))(define-macro (globalize expr . rest) "(globalize expr) - - Macro will get the value of the expression and add each method as function to global - scope." (let* ((env (current-environment)) (obj (eval expr env)) (name (gensym "name")) (env-name (gensym "env-name")) (make-name (if (pair? rest) (let ((pre (symbol->string (car rest)))) (lambda (name) (string->symbol (concat pre name)))) string->symbol))) (quasiquote (let (((unquote name) (unquote expr))) (unquote-splicing (filter pair? (map (lambda (key) (if (and (not (match /^_/ key)) (function? (. obj key))) (let* ((args (gensym "args"))) (quasiquote (define-global ((unquote (make-name key)) unquote args) (apply (. (unquote name) (unquote key)) (unquote args))))))) (array->list (--> Object (keys obj))))))))))(define (single list) "(single list) - -Function check if argument is list with single element" (and (pair? list) (not (cdr list))))(define (iterator? x) "(iterator? x) - - Function check if value is JavaScript iterator object" (and (object? x) (procedure? (. x Symbol.iterator))))(define-macro (.. expr) "(.. foo.bar.baz) - -Macro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts))))))))(set-special! "#:" (quote gensym-interal) lips.specials.LITERAL)(define (gensym-interal symbol) "(gensym-interal symbol) - -Parser extension that create new quoted named gensym." (quasiquote (quote (unquote (gensym symbol)))))(define (plain-object? x) "(plain-object? x) - -Function check if value is plain JavaScript object. Created using object macro." (and (== (--> (type x) (cmp "object")) 0) (eq? (. x (quote constructor)) Object)))(define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o) - -Function test if argumnet is JavaScript typed array (Scheme byte vector)." (instanceof TypedArray o))))(define (symbol->string s) "(symbol->string symbol) - -Function convert LIPS symbol to string." (if (symbol? s) (let ((name s.__name__)) (if (string? name) name (--> name (toString))))))(define (string->symbol string) "(string->symbol string) - -Function convert string to LIPS symbol." (and (string? string) (%as.data (new (. lips "LSymbol") string))))(define (alist->object alist) "(alist->object alist) - -Function convert alist pairs to JavaScript object." (if (pair? alist) (alist.toObject) (alist->object (new lips.Pair undefined ()))))(define (parent.frames) "(parent.frames) - -Funcion return list of environments from parent frames (lambda function calls)" (let iter ((result (quote ())) (frame (parent.frame 1))) (if (eq? frame (interaction-environment)) (cons frame result) (if (null? frame) result (let ((parent.frame (--> frame (get (quote parent.frame) (object :throwError #f))))) (if (function? parent.frame) (iter (cons frame result) (parent.frame 0)) result))))))(define-macro (wait time . expr) "(wait time . expr) - -Function return promise that will resolve with evaluating the expression after delay." (quasiquote (promise (timer (unquote time) (resolve (begin (unquote-splicing expr)))))))(define (pair-map fn seq-list) "(pair-map fn list) - -Function call fn argument for pairs in a list and return combined list with -values returned from function fn. It work like the map but take two items from list" (let iter ((seq-list seq-list) (result (quote ()))) (if (null? seq-list) result (if (and (pair? seq-list) (pair? (cdr seq-list))) (let* ((first (car seq-list)) (second (cadr seq-list)) (value (fn first second))) (if (null? value) (iter (cddr seq-list) result) (iter (cddr seq-list) (cons value result))))))))(define (object-expander readonly expr . rest) "(object-expander reaonly '(:foo (:bar 10) (:baz (1 2 3)))) - -Recursive function helper for defining LIPS code for create objects -using key like syntax." (let ((name (gensym "name")) (quot (if (null? rest) #f (car rest)))) (if (null? expr) (quasiquote (alist->object ())) (quasiquote (let (((unquote name) (alist->object (quote ())))) (unquote-splicing (pair-map (lambda (key value) (if (not (key? key)) (let ((msg (string-append (type key) " " (repr key) " is not a symbol!"))) (throw msg)) (let ((prop (key->string key))) (if (and (pair? value) (key? (car value))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote (object-expander readonly value)))) (if quot (quasiquote (set-obj! (unquote name) (unquote prop) (quote (unquote value)))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote value)))))))) expr)) (unquote (if readonly (quasiquote (Object.freeze (unquote name))))) (unquote name))))))(define-macro (object . expr) "(object :name value) - -Macro that create JavaScript object using key like syntax." (try (object-expander #f expr) (catch (e) (error e.message))))(define-macro (object-literal . expr) "(object-literal :name value) - -Macro that create JavaScript object using key like syntax. This is similar, -to object but all values are quoted. This macro is used with & object literal." (try (object-expander #t expr #t) (catch (e) (error e.message))))(define (alist->assign desc . sources) "(alist->assign alist . list-of-alists) - -Function that work like Object.assign but for LIPS alist." (for-each (lambda (source) (for-each (lambda (pair) (let* ((key (car pair)) (value (cdr pair)) (d-pair (assoc key desc))) (if (pair? d-pair) (set-cdr! d-pair value) (append! desc (list pair))))) source)) sources) desc)(define (key? symbol) "(key? symbol) - -Function check if symbol is key symbol, have colon as first character." (and (symbol? symbol) (== (--> (substring (symbol->string symbol) 0 1) (cmp ":")) 0)))(define (key->string symbol) "(key->string symbol) - -If symbol is key it convert that to string - remove colon." (if (key? symbol) (substring (symbol->string symbol) 1)))(define (%as.data obj) "(%as.data obj) - -Mark object as data to stop evaluation." (if (object? obj) (begin (set-obj! obj (quote data) #t) obj)))(define (%hidden-props obj) "(%hidden-props obj) - -Function return hidden names of an object, for ES6 class prototype -it return all methods since they are indistinguishable from hidden property -created using defineProperty." (let* ((descriptors (Object.getOwnPropertyDescriptors obj)) (names (Object.keys descriptors))) (--> names (filter (lambda (name) (let ((descriptor (. descriptors name))) (eq? descriptor.enumerable #f)))))))(define (dir obj . rest) "(dir obj) - -Function return all props on the object including those in prototype chain." (if (or (null? obj) (eq? obj Object.prototype)) () (let ((proto (if (null? rest) #f (car rest))) (names (Object.getOwnPropertyNames obj))) (if (not proto) (let ((hidden (%hidden-props obj))) (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) (append (array->list (--> names (map (unary string->symbol)))) (dir (Object.getPrototypeOf obj) #t)))))(define (tree-map f tree) "(tree-map fn tree) - -Tree version of map. Function is invoked on every leaf." (if (pair? tree) (cons (tree-map f (car tree)) (tree-map f (cdr tree))) (f tree)))(define (native.number x) "(native.number obj) - -If argument is number it will convert to native number." (if (number? x) (value x) x))(define (value obj) "(value obj) - -Function unwrap LNumbers and convert nil value to undefined." (if (eq? obj ()) undefined (if (number? obj) ((. obj "valueOf")) obj)))(define-macro (define-formatter-rule . patterns) "(rule-pattern pattern) - -Anaphoric Macro for defining patterns for formatter. With Ahead, Pattern and * defined values." (let ((rules (gensym "rules"))) (quasiquote (let (((unquote rules) lips.Formatter.rules) (Ahead (lambda (pattern) (let ((Ahead (.. lips.Formatter.Ahead))) (new Ahead (if (string? pattern) (new RegExp pattern) pattern))))) (* (Symbol.for "*")) (Pattern (lambda (pattern flag) (new lips.Formatter.Pattern (list->array pattern) (if (null? flag) undefined flag))))) (unquote-splicing (map (lambda (pattern) (quasiquote (--> (unquote rules) (push (tree->array (tree-map native.number (unquote-splicing pattern))))))) patterns))))))(define-syntax cond (syntax-rules (=> else) ((cond (else else1 else2 ...)) (if #t (begin else1 else2 ...))) ((cond (test => receiver) more-clause ...) (let ((t test)) (cond/maybe-more t (receiver t) more-clause ...))) ((cond (generator guard => receiver) more-clause ...) (call-with-values (lambda () generator) (lambda t (cond/maybe-more (apply guard t) (apply receiver t) more-clause ...)))) ((cond (test) more-clause ...) (let ((t test)) (cond/maybe-more t t more-clause ...))) ((cond (test body1 body2 ...) more-clause ...) (cond/maybe-more test (begin body1 body2 ...) more-clause ...))) "(cond (predicate? . body) - (predicate? . body) - (else . body)) - -Macro for condition checks. For usage instead of nested ifs.")(define-syntax cond/maybe-more (syntax-rules () ((cond/maybe-more test consequent) (if test consequent)) ((cond/maybe-more test consequent clause ...) (if test consequent (cond clause ...)))) "(cond/maybe-more test consequent ...) - -Helper macro used by cond.")(define-macro (cond . list) "(cond (predicate? . body) - (predicate? . body)) -Macro for condition check. For usage instead of nested ifs." (if (pair? list) (let* ((item (car list)) (first (car item)) (forms (cdr item)) (rest (cdr list))) (quasiquote (if (unquote first) (begin (unquote-splicing forms)) (unquote (if (and (pair? rest) (or (eq? (caar rest) #t) (eq? (caar rest) (quote else)))) (quasiquote (begin (unquote-splicing (cdar rest)))) (if (not (null? rest)) (quasiquote (cond (unquote-splicing rest))))))))) ()))(define (%r re . rest) "(%r re) - -Create new regular expression from string, to not break Emacs formatting" (if (null? rest) (new RegExp re) (new RegExp re (car rest))))(define (interaction-environment) "(interaction-environment) - -Function return interaction environement equal to lips.env can be overwritten, -when creating new interpreter with lips.Interpreter." **interaction-environment**)(define (current-output-port) "(current-output-port) - -Function return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdout)))))(define (current-error-port) "(current-output-port) - -Function return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stderr)))))(define (current-input-port) "current-input-port) - -Function return default stdin port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdin)))))(define (regex? x) "(regex? x) - -Function return true of value is regular expression, it return false otherwise." (== (--> (type x) (cmp "regex")) 0))(define (set-repr! type fn) "(add-repr! type fn) - -Function add string represention to the type, which should be constructor function. - -Function fn should have args (obj q) and it should return string, obj is vlaue that -need to be converted to string, if the object is nested and you need to use `repr`, -it should pass second parameter q to repr, so string will be quoted when it's true. - -e.g.: (lambda (obj q) (string-append \"<\" (repr obj q) \">\"))" (typecheck "add-repr!" type "function") (typecheck "add-repr!" fn "function") (ignore (--> lips.repr (set type fn))))(define (unset-repr! type) "(unset-repr! type) - -Function remove string represention to the type, which should be constructor function, -added by add-repr! function." (typecheck "unset-repr!" type "function") (ignore (--> lips.repr (delete type))))(set-special! "&" (quote object-literal) lips.specials.SPLICE)(set-repr! Object (lambda (x q) (concat "&(" (--> (Object.getOwnPropertyNames x) (map (lambda (key) (concat ":" key " " (repr (. x key) q)))) (join " ")) ")")))(define (bound? x . rest) "(bound? x [env]) - -Function check if variable is defined in given environement or interaction environment -if not specified." (let ((env (if (null? rest) (interaction-environment) (car rest)))) (try (begin (--> env (get x)) #t) (catch (e) #f))))(define (environment-bound? env x) "(environment-bound? env symbol) - -Function check if symbol is bound variable similar to bound?." (typecheck "environment-bound?" env "environment" 1) (typecheck "environment-bound?" x "symbol" 2) (bound? x env))(define (qsort e predicate) "(qsort list predicate) - -Sort the list using quick sort alorithm according to predicate." (if (or (null? e) (<= (length e) 1)) e (let loop ((left ()) (right ()) (pivot (car e)) (rest (cdr e))) (if (null? rest) (append (append (qsort left predicate) (list pivot)) (qsort right predicate)) (if (predicate (car rest) pivot) (loop (append left (list (car rest))) right pivot (cdr rest)) (loop left (append right (list (car rest))) pivot (cdr rest)))))))(define (sort list . rest) "(sort list [predicate]) - -Sort the list using optional predicate function. if not function is specified -it will use <= and sort in increasing order." (let ((predicate (if (null? rest) <= (car rest)))) (typecheck "sort" list "pair") (typecheck "sort" predicate "function") (qsort list predicate)))(define (every fn list) "(every fn list) - -Function call function fn on each item of the list, if every value is true -it will return true otherwise it return false." (if (null? list) #t (and (fn (car list)) (every fn (cdr list)))))(define (zip . args) "(zip list1 list2 ...) - -Create one list by taking each element of each list." (if (null? args) () (if (some null? args) () (cons (map car args) (apply zip (map cdr args))))))(define-macro (promise . body) "(promise . body) - -Anaphoric macro that expose resolve and reject functions from JS promise" (quasiquote (new Promise (lambda (resolve reject) (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message))))))))(define-macro (timer time . body) "(timer time . body) - -Macro evaluate expression after delay, it return timer. To clear the timer you can use -native JS clearTimeout function." (quasiquote (setTimeout (lambda () (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message))))) (unquote time))))(define (defmacro? obj) "(defmacro? expression) - -Function check if object is macro and it's expandable." (and (macro? obj) (. obj (quote defmacro))))(define (n-ary n fn) "(n-ary n fn) - -Return new function that limit number of arguments to n." (lambda args (apply fn (take n args))))(define (take n lst) "(take n list) - -Return n first values of the list." (let iter ((result (quote ())) (i n) (lst lst)) (if (or (null? lst) (<= i 0)) (reverse result) (iter (cons (car lst) result) (- i 1) (cdr lst)))))(define unary (%doc "(unary fn) - -Function return new function with arguments limited to one." (curry n-ary 1)))(define binary (%doc "(binary fn) - -Function return new function with arguments limited to two." (curry n-ary 2)))(define (%class-lambda expr) "(class-lambda expr) - -Return lambda expression where input expression lambda have `this` as first argument." (let ((args (gensym (quote args)))) (quasiquote (lambda (unquote args) (apply (unquote (cadr expr)) this (unquote args))))))(define (%class-lambda expr) "(%class-lambda expr) - -Define lambda that have self is first argument. The expr is in a form: -(constructor (lambda (self ...) . body)) as given by define-class macro." (let ((args (cdadadr expr))) (quasiquote (lambda ((unquote-splicing args)) ((unquote (cadr expr)) this (unquote-splicing args))))))(define (%class-method-name expr) "(%class-method-name expr) - -Helper function that allow to use [Symbol.asyncIterator] inside method name." (if (pair? expr) (car expr) (list (quote quote) expr)))(define-macro (define-class name parent . body) "(define-class name parent . body) - -Define class - JavaScript function constructor with prototype. - -usage: - - (define-class Person Object - (constructor (lambda (self name) - (set-obj! self '_name name))) - (hi (lambda (self) - (display (string-append self._name \" say hi\")) - (newline)))) - (define jack (new Person \"Jack\")) - (jack.hi)" (let iter ((functions (quote ())) (constructor (quote ())) (lst body)) (if (null? lst) (quasiquote (begin (define (unquote name) (unquote (if (null? constructor) (quasiquote (lambda ())) (%class-lambda constructor)))) (set-obj! (unquote name) (Symbol.for "__class__") #t) (unquote (if (and (not (null? parent)) (not (eq? parent (quote Object)))) (quasiquote (begin (set-obj! (unquote name) (quote prototype) (Object.create (. (unquote parent) (quote prototype)))) (set-obj! (. (unquote name) (quote prototype)) (quote constructor) (unquote name)))))) (unquote-splicing (map (lambda (fn) (quasiquote (set-obj! (. (unquote name) (quote prototype)) (unquote (%class-method-name (car fn))) (unquote (%class-lambda fn))))) functions)))) (let ((item (car lst))) (if (eq? (car item) (quote constructor)) (iter functions item (cdr lst)) (iter (cons item functions) constructor (cdr lst)))))))(define-syntax class (syntax-rules () ((_) (error "class: parent required")) ((_ parent body ...) (let () (define-class temp parent body ...) temp))) "(class <parent> body ...) - -Macro allow to create anonymous classes. See define-class for details.")(define (make-tags expr) "(make-tags expression) - -Function that return list structure of code with better syntax then raw LIPS" (quasiquote (h (unquote (let ((val (car expr))) (if (key? val) (key->string val) val))) (alist->object ((unquote (quote quasiquote)) (unquote (pair-map (lambda (car cdr) (quasiquote ((unquote (key->string car)) (unquote (quote unquote)) (unquote cdr)))) (cadr expr))))) (unquote (if (not (null? (cddr expr))) (if (and (pair? (caddr expr)) (let ((s (caaddr expr))) (and (symbol? s) (eq? s (quote list))))) (quasiquote (list->array (list (unquote-splicing (map make-tags (cdaddr expr)))))) (caddr expr)))))))(define (%sxml h expr) "(%sxml h expr) - -Helper function that render expression using create element function." (let* ((have-attrs (and (not (null? (cdr expr))) (pair? (cadr expr)) (eq? (caadr expr) (quote @)))) (attrs (if have-attrs (cdadr expr) ())) (rest (if have-attrs (cddr expr) (cdr expr)))) (quasiquote ((unquote h) (unquote (let* ((symbol (car expr)) (name (symbol->string symbol))) (if (char-lower-case? (car (string->list name))) name symbol))) (alist->object ((unquote (quote quasiquote)) (unquote (map (lambda (pair) (cons (symbol->string (car pair)) (list (quote unquote) (cadr pair)))) attrs)))) (unquote-splicing (if (null? rest) () (let ((first (car rest))) (if (pair? first) (map (lambda (expr) (%sxml h expr)) rest) (list first)))))))))(define-macro (pragma->sxml pragma) (quasiquote (define-macro (sxml expr) "(sxml expr) - -Macro for JSX like syntax but with SXML. -e.g. usage: - -(sxml (div (@ (data-foo \"hello\") - (id \"foo\")) - (span \"hello\") - (span \"world\")))" (%sxml (quote (unquote pragma)) expr))))(pragma->sxml h)(define-macro (with-tags expr) "(with-tags expression) - -Macro that evalute LIPS shorter code for S-Expression equivalent of JSX. -e.g.: - -(with-tags (:div (:class \"item\" :id \"item-1\") - (list (:span () \"Random Item\") - (:a (:onclick (lambda (e) (alert \"close\"))) - \"close\")))) - -Above expression can be passed to function that renders JSX (like render in React, Preact) -To get the string from the macro you can use vhtml library from npm." (make-tags expr))(define (get-script url) "(get-script url) - -Load JavaScript file in browser by adding script tag to head of the current document." (if (not (bound? (quote document))) (throw (new Error "get-script: document not defined")) (let ((script (document.createElement "script"))) (new Promise (lambda (resolve reject) (set-obj! script (quote src) url) (set-obj! script (quote onload) (lambda () (resolve))) (set-obj! script (quote onerror) (lambda () (reject "get-script: Failed to load"))) (if document.head (document.head.appendChild script)))))))(define (gensym? value) "(gensym? value) - -Function return #t if value is symbol and it's gensym. It returns #f otherwise." (and (symbol? value) (--> value (is_gensym))))(define (degree->radians x) "(degree->radians x) - -Convert degree to radians." (* x (/ Math.PI 180)))(define (radians->degree x) "(radians->degree x) - -Convert radians to degree." (* x (/ 180 Math.PI)))(define-syntax while (syntax-rules () ((_ predicate body ...) (do () ((not predicate)) body ...))) "(while cond . body) - -Macro that create a loop, it exectue body until cond expression is false.")(define-syntax ++ (syntax-rules () ((++ x) (let ((tmp (+ x 1))) (set! x tmp) tmp))) "(++ variable) - -Macro that work only on variables and increment the value by one.")(define-syntax -- (syntax-rules () ((-- x) (let ((tmp (- x 1))) (set! x tmp) tmp))) "(-- variable) - -Macro that decrement the value it work only on symbols")(define (pretty-format pair) "(pretty-format pair) - -Function return pretty printed string from pair expression." (typecheck "pretty-pair" pair "pair") (--> (new lips.Formatter (repr pair #t)) (break) (format)))(define (reset) "(reset) - -Function reset environment and remove all user defined variables." (let-env **interaction-environment** (let ((defaults **interaction-environment-defaults**) (env **interaction-environment**)) (--> env (list) (forEach (lambda (name) (if (not (--> defaults (includes name))) (--> env (unset name)))))))))(define (make-list n . rest) (if (or (not (integer? n)) (<= n 0)) (throw (new Error "make-list: first argument need to be integer larger then 0")) (let ((fill (if (null? rest) undefined (car rest)))) (array->list (--> (new Array n) (fill fill))))))(define (range n) "(range n) - -Function return list of n numbers from 0 to n - 1" (typecheck "range" n "number") (array->list (--> (new Array n) (fill 0) (map (lambda (_ i) i)))))(define-macro (do-iterator spec cond . body) "(do-iterator (var expr) (test) body ...) - -Macro iterate over iterators (e.g. create with JavaScript generator function) -it works with normal and async iterators. You can loop over infinite iterators -and break the loop if you want, using expression like in do macro, long sync iterators -will block main thread (you can't print 1000 numbers from inf iterators, -because it will freeze the browser), but if you use async iterators you can process -the values as they are generated." (let ((gen (gensym "name")) (name (car spec)) (async (gensym "async")) (sync (gensym "sync")) (iterator (gensym "iterator")) (test (if (null? cond) #f (car cond))) (next (gensym "next")) (stop (gensym "stop")) (item (gensym "item"))) (quasiquote (let* (((unquote gen) (unquote (cadr spec))) ((unquote sync) (. (unquote gen) Symbol.iterator)) ((unquote async) (. (unquote gen) Symbol.asyncIterator)) ((unquote iterator)) ((unquote next) (lambda () ((. (unquote iterator) "next"))))) (if (or (procedure? (unquote sync)) (procedure? (unquote async))) (begin (set! (unquote iterator) (if (procedure? (unquote sync)) ((unquote sync)) ((unquote async)))) (let* (((unquote item) ((unquote next))) ((unquote stop) #f) ((unquote name) (. (unquote item) "value"))) (while (not (or (eq? (. (unquote item) "done") #t) (unquote stop))) (if (unquote test) (set! (unquote stop) #t) (begin (unquote-splicing body))) (set! (unquote item) ((unquote next))) (set! (unquote name) (. (unquote item) "value"))))))))))(set-repr! Set (lambda () "#<Set>"))(set-repr! Map (lambda () "#<Met>"))(define (native-symbol? x) "(native-symbol? object) - -Function check if value is JavaScript symbol." (and (string=? (type x) "symbol") (not (symbol? x))))(set-special! "’" (quote warn-quote))(define-macro (warn-quote) "(warn-quote) - -Simple macro that throw error, when you try to use ’ symbol as quote in code" (throw (new Error (string-append "You're using invalid quote character run: " "(set-special! \"’\" 'quote)" " to allow running this type of quote"))))(define-macro (quote-promise expr) "(quote-promise expr) -'>expr - -Macro used to escape promise the whole expression, will be wrapped -with JavaScript class that behave like Promise but will not -auto resolve like normal promise." (quasiquote (let ((env)) (set! env (current-environment)) (env.set (Symbol.for "__promise__") #t) (unquote expr))))(define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value))(define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body) - -Macro add mapping for variables var from specified env, -Macro work similar to let-env but lexical scope is working with it." (let ((env-name (gensym (quote env)))) (quasiquote (let (((unquote env-name) (unquote env))) (let (unquote (map (lambda (pair) (quasiquote ((unquote (car pair)) (--> (unquote env-name) (get (quote (unquote (cadr pair)))))))) spec)) (unquote-splicing body))))))(define-macro (let-std spec . body) "(let-std ((name var)) . body) - -Macro that create aliases for variables in global environment. -This is needed so user don't change constants like stdin or stdout -that use taken from lexical scope. The function still can use those -from interaction-environment." (quasiquote (let-env-values lips.env.__parent__ (unquote spec) (unquote-splicing body))))(define (apropos name) "(apropos name) - -Search environment and display names that match the given name. -name can be regex, string or symbol." (typecheck "apropos" name (quote ("string" "regex" "symbol"))) (let ((regex (lambda (string) (new RegExp (escape-regex string))))) (filter (cond ((string? name) (regex name)) ((symbol? name) (regex (symbol->string name))) (else name)) (env))))(set-special! "#," (quote sharp-comma))(define **reader-ctor-list** (quote ()))(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**)))))(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...))))))))))(define (promisify fn) "(promisify fn) - -Simple function for adding promises to NodeJS callback based function. -Function tested only with fs module." (lambda args (new Promise (lambda (resolve reject) (apply fn (append args (list (lambda (err data) (if (null? err) (resolve data) (reject err))))))))))(define-macro (list* . args) "(list* arg1 ...) - -Parallel version of list." (let ((result (gensym "result"))) (quasiquote (let (((unquote result) (vector))) (unquote-splicing (map (lambda (arg) (quasiquote (--> (unquote result) (push (quote-promise (unquote arg)))))) args)) (map await (vector->list (unquote result)))))))(define-macro (%not-implemented name) "(not-implemented name) - -Returns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ") - -This function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented"))))))))(define-macro (%make-env name . names) "(%make-env name f1 f2 ...) - -Create new Environment with given name and defined symbols in it from global env. -If given function name f1 f2 ... don't exists, it will define function that -throw exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name))))(define Y (lambda (h) "(Y f) - - _ __ __ _ _ _ _ __ __ _ _ _ - / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\ -+ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + + -| \\ / | \\ \\ | | |__ | | \\ / | |__ | | | -| | | | / \\ | | __| | | | | | __| | | | -| | | | / /\\ \\ | | | | | | | | | | | | -+ |_| + /_/ \\_\\ + |_| + + |_| |_| + + + - \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args)))))))(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs))))(define (environment? obj) "(environment? obj) - -Function check if object is LIPS environment." (instanceof lips.Environment obj))(define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path) - -Read file from url or file system. If binary is false it will return -string that contain all the content. For HTTP requests, If binary -is false it will: when in browser return ArrayBuffer and in Node -it will return Buffer object. When reading from file system -in both cases it will return Buffer objects. - -The code that use those function, in binary mode, need to check -if the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path)))))))(define %read-binary-file (curry %read-file #t))(define %read-text-file (curry %read-file #f))(define (response->content binary res) "(response->text binary res) - -Function read all text from Node.js HTTP response object. If binary argument is -true it will return Buffer object that can be converted to u8vector. - -***Warrning:*** it may overflow the stack (part of Node) when converting -whole buffer to u8vector." (let ((result (vector))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" (lambda (chunk) (result.push (Buffer.from chunk "binary")))) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join "")))))))))(define response->buffer (curry response->content #t))(define response->text (curry response->content #f))(define http-get (if (eq? self window) (lambda (url binary) "(http-get url) - -Node.js Function that send HTTP Request and return string or -binary Buffer object." (throw (new Error "http-get: function is Node.js only."))) (let* ((http (. (require "http") (quote get))) (https (. (require "https") (quote get)))) (lambda (url binary) "(http-get url) - -Node.js Function that send HTTP Request and return string or -binary Buffer object." (let ((request (if (null? (url.match #/^https/)) http https))) (new Promise (lambda (resolve reject) (--> (request url (lambda (res) (if (= res.statusCode 200) (resolve (response->content binary res)) (let ((code res.statusCode)) (res.resume) (reject (string-append "Request return " (number->string code))))))) (on "error" reject)))))))))(define (buffer->u8vector bin) "(buffer->u8vector bin) - -Cross platform function that can be used in both Node and Browser. -It can be used together with %read-file or %read-binary-file and convert -the result ArrayBuffer or Buffer to u8vector." (if (instanceof ArrayBuffer bin) (new Uint8Array bin) (Uint8Array.from bin)))(define string-append concat)(define = ==)(define remainder %)(define -inf.0 Number.NEGATIVE_INFINITY)(define +inf.0 Number.POSITIVE_INFINITY)(define procedure? function?)(define expt **)(define list->vector list->array)(define vector->list array->list)(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body) - -Macro that creates special symbol macro for evaluator similar to build in , or `. -It's like alias for real macro. Similar to CL reader macros but it receive already -parsed code like normal macros. Type can be SPLICE or LITERAL symbols. -ALL default symbol macros are literal." (let* ((name (car spec)) (symbol (cadr spec)) (args (cddr spec))) (quasiquote (begin (set-special! (unquote symbol) (quote (unquote name)) (unquote (string->symbol (concat "lips.specials." (symbol->string type))))) (define-macro ((unquote name) (unquote-splicing args)) (unquote-splicing rest))))))(set-special! "#" (quote vector-literal) lips.specials.SPLICE)(define-macro (vector-literal . args) (if (not (or (pair? args) (eq? args ()))) (throw (new Error (concat "Parse Error: vector require pair got " (type args) " in " (repr args)))) (let ((v (list->array args))) (Object.freeze v) v)))(define-syntax vector (syntax-rules () ((_ arg ...) (list->array (list arg ...)))) "(vector 1 2 3 (+ 3 1)) -#(1 2 3 4) - -Macro for defining vectors (JavaScript arrays). Vectors literals are -automatically quoted. So you can use expressions inside them. Only other -literals, like other vectors or object.")(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")"))))(define (eqv? a b) "(eqv? a b) - -Function compare the values. It return true if they are the same, they -need to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (cond ((a.isNaN) (b.isNaN)) ((and (zero? a) (zero? b)) (eq? a._minus b._minus)) ((and (complex? a) (complex? b)) (let ((re.a (real-part a)) (re.b (real-part b)) (im.a (imag-part a)) (im.b (imag-part b))) (and (if (and (zero? re.a) (zero? re.b)) (eq? (. re.a (quote _minus)) (. re.b (quote _minus))) #t) (if (and (zero? im.a) (zero? im.b)) (eq? (. im.a (quote _minus)) (. im.b (quote _minus))) #t) (or (= re.a re.b) (and (--> re.a (isNaN)) (--> re.b (isNaN)))) (or (= im.a im.b) (and (--> im.a (isNaN)) (--> im.b (isNaN))))))) (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f))(define (equal? a b) "(equal? a b) - -Function check if values are equal if both are pair or array -it compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b))))(define make-promise (lambda (proc) "(make-promise fn) - -Function create promise from a function." (typecheck "make-promise" proc "function") (let ((result-ready? #f) (result #f)) (let ((promise (lambda () (if result-ready? result (let ((x (proc))) (if result-ready? result (begin (set! result-ready? #t) (set! result x) result))))))) (set-obj! promise (Symbol.for "promise") #t) (set! promise.toString (lambda () (string-append "#<promise - " (if result-ready? (string-append "forced with " (type result)) "not forced") ">"))) promise))))(define-macro (delay expression) "(delay expression) - -Macro will create a promise from expression that can be forced with (force)." (quasiquote (make-promise (lambda () (unquote expression)))))(define (force promise) "(force promise) - -Function force the promise and evaluate delayed expression." (promise))(define (promise? obj) "(promise? obj) - -Function check if value is a promise created with delay or make-promise." (string=? (type obj) "promise"))(define (positive? x) "(positive? x) - -Function check if number is larger then 0" (typecheck "positive?" x "number") (> x 0))(define (negative? x) "(negative? x) - -Function check if number is smaller then 0" (typecheck "negative?" x "number") (< x 0))(define (zero? x) "(zero? x) - -Function check if number is equal to 0" (typecheck "zero?" x "number") (= x 0))(define (quotient a b) "(quotient a b) - -Return quotient from divition as integer." (typecheck "quotient" a "number") (typecheck "quotient" b "number") (if (zero? b 0) (throw (new Error "quotient: divition by zero")) (let ((quotient (/ a b))) (if (integer? quotient) quotient (if (> quotient 0) (floor quotient) (ceiling quotient))))))(define (number->string x . rest) "(number->string x [radix]) - -Function convert number to string with optional radix (number base)." (typecheck "number->string" x "number" 1) (let ((radix (if (null? rest) 10 (car rest)))) (typecheck "number->string" radix "number" 2) (--> x (toString (--> radix (valueOf))))))(define (boolean? x) "(boolean? x) - -Function return true if value is boolean." (string=? (type x) "boolean"))(define (vector-ref vector i) "(vector-ref vector i) - -Return i element from vector." (typecheck "number->string" vector "array" 1) (typecheck "number->string" i "number" 2) (. vector i))(define (vector-set! vector i obj) "(vector-set! vector i obj) - -Set obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj))(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type)))))(define (real? x) "(real? x) - -Function check if argument x is real." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (%number-type "complex" x) (let ((i (imag-part x))) (and (zero? i) (exact? i)))) (%number-type (quote ("float" "bigint" "rational")) x))))(define (integer? x) "(integer? x) - -Function check if argument x is integer." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "bigint" x) (and (%number-type "float" x) (= (modulo x 2) 1)))))(define (complex? x) "(complex? x) - -Function check if argument x is complex." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (%number-type (quote ("complex" "float" "bigint" "rational")) x))))(define (rational? x) "(rational? x) - -Function check if value is rational." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "rational" x) (integer? x))))(define (typecheck-args _type name _list) "(typecheck-args args type) - -Function check if all items in array are of same type." (let iter ((n 1) (_list _list)) (if (pair? _list) (begin (typecheck name (car _list) _type n) (iter (+ n 1) (cdr _list))))))(define numbers? (curry typecheck-args "number"))(define (max . args) "(max n1 n2 ...) - -Return maximum of it's arguments." (numbers? "max" args) (apply (.. Math.max) args))(define (min . args) "(min n1 n2 ...) - -Return minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) args))(define (make-rectangular re im) "(make-rectangular im re) - -Create complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t)))))(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__)))))(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n)))(define (exact->inexact n) "(exact->inexact n) - -Convert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (exact->inexact (. n (quote __im__))) :re (exact->inexact (. n (quote __re__))))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n)))(define (inexact->exact n) "(inexact->exact number) - -Funcion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n))(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan"))(define _this_env (current-environment))(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n) - -Function calculate " name " math operation (it call JavaScript Math)." name " function.")) (iter (cdr fns)))))(define (modulo a b) "(modulo a b) - -Function return modulo operation on it's argumennts." (typecheck "modulo" a "number" 1) (typecheck "modulo" b "number" 2) (- a (* b (floor (/ a b)))))(define (remainder__ a b) "(modulo a b) - -Function return reminder from division operation." (typecheck "remainder" a "number" 1) (typecheck "remainder" b "number" 2) (- a (* b (truncate (/ a b)))))(define (list-tail l k) "(list-tail list k) - -Returns the sublist of list obtained by omitting the first k elements." (typecheck "list-tail" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-tail: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) l)))(define (list-ref l k) "(list-ref list n) - -Returns n element of a list." (typecheck "list-ref" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l)))))(define (not x) "(not x) - -Function return true if value is false and false otherwise." (if x #f #t))(define (rationalize number tolerance) "(rationalize number tolerance) - -Function returns simplest rational number differing from number by no more -than the tolerance." (typecheck "rationalize" number "number" 1) (typecheck "rationalize" tolerance "number" 2) (lips.rationalize number tolerance))(define (%mem/search access op obj list) "(%member obj list function) - -Helper method to get first list where car equal to obj -using provied functions as comparator." (if (null? list) #f (if (op (access list) obj) list (%mem/search access op obj (cdr list)))))(define (memq obj list) "(memq obj list) - -Function return first object in the list that match using eq? function." (typecheck "memq" list (quote ("nil" "pair"))) (%mem/search car eq? obj list))(define (memv obj list) "(memv obj list) - -Function return first object in the list that match using eqv? function." (typecheck "memv" list (quote ("nil" "pair"))) (%mem/search car eqv? obj list))(define (member obj list) "(member obj list) - -Function return first object in the list that match using equal? function." (typecheck "member" list (quote ("nil" "pair"))) (%mem/search car equal? obj list))(define (%assoc/acessor name) "(%assoc/acessor name) - -Function return carr with typecheck using give name." (lambda (x) (typecheck name x "pair") (caar x)))(define (%assoc/search op obj alist) "(%assoc/search op obj alist) - -Generic function that used in assoc functions with defined comparator -function." (typecheck "assoc" alist (vector "nil" "pair")) (let ((ret (%mem/search (%assoc/acessor "assoc") op obj alist))) (if ret (car ret) ret)))(define assoc (%doc "(assoc obj alist) - -Function return pair from alist that match given key using equal? check." (curry %assoc/search equal?)))(define assq (%doc "(assq obj alist) - -Function return pair from alist that match given key using eq? check." (curry %assoc/search eq?)))(define assv (%doc "(assv obj alist) - -Function return pair from alist that match given key using eqv? check." (curry %assoc/search eqv?)))(define (make-string k . rest) "(make-string k [char]) - -Function return new string with k elements, if char is provied -it's filled with that character." (let ((char (if (null? rest) #\space (car rest)))) (typecheck "make-string" k "number" 1) (typecheck "make-string" char "character" 2) (let iter ((result (quote ())) (k k)) (if (<= k 0) (list->string result) (iter (cons char result) (- k 1))))))(define (string . args) "(string chr1 chr2 ...) - -Function create new string from it's arguments. Each argument -Need to be a character object." (for-each (lambda (x) (typecheck "string" x "character")) args) (list->string args))(define (string-copy string) "(string-copy string) - -Returns a copy of the given string." (typecheck "string-copy" string "string") (--> string (clone)))(define (string-fill! string char) "(string-fill! symbol char) - -Function destructively fill the string with given character." (typecheck "string-fill!" string "string" 1) (typecheck "string-fill!" char "character" 2) (--> string (fill char)))(define (identity n) "(identity n) - -No op function. it just returns its argument." n)(define (string-copy x) "(string-copy x) - -Create new string based of given argument." (typecheck "string-copy" x "string") (lips.LString x))(define (list->string _list) "(list->string _list) - -Function return string from list of characters." (let ((array (list->array (map (lambda (x) (typecheck "list->string" x "character") (x.valueOf)) _list)))) (--> array (join ""))))(define (string->list string) "(string->list string) - -Function return list of characters created from string." (typecheck "string->list" string "string") (array->list (--> string (split "") (map (lambda (x) (lips.LCharacter x))))))(define-macro (string-set! object index char) "(string-set! object index char) - -Macro that replace character in string in given index, it create new JavaScript -string and replace old value. Object need to be symbol that point to variable -that hold the string." (typecheck "string-set!" object "symbol") (let ((chars (gensym "chars"))) (quasiquote (begin (typecheck "string-set!" (unquote object) "string") (typecheck "string-set!" (unquote index) "number") (typecheck "string-set!" (unquote char) "character") (let (((unquote chars) (list->vector (string->list (unquote object))))) (set-obj! (unquote chars) (unquote index) (unquote char)) (set! (unquote object) (list->string (vector->list (unquote chars)))))))))(define (string-length string) "(string-length string) - -Function return length of the string." (typecheck "string-ref" string "string") (. string (quote length)))(define (string-ref string k) "(string-ref string k) - -Function return character inside string at given zero-based index." (typecheck "string-ref" string "string" 1) (typecheck "string-ref" k "number" 2) (lips.LCharacter (--> string (get k))))(define (%string-cmp name string1 string2) "(%string-cmp name a b) - -Function compare two strings and return 0 if they are equal, --1 second is smaller and 1 if is larget. The function compare -the codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (cmp string2)))(define (string=? string1 string2) "(string=? string1 string2) - -Function check if two string s are equal." (= (%string-cmp "string=?" string1 string2) 0))(define (string<? string1 string2) "(string<? string1 string2) - -Function return true if second string is smaller then the first one." (= (%string-cmp "string<?" string1 string2) -1))(define (string>? string1 string2) "(string<? string1 string2) - -Function return true if second string is larger then the first one." (= (%string-cmp "string>?" string1 string2) 1))(define (string<=? string1 string2) "(string<? string1 string2) - -Function return true if second string is not larger then the first one." (< (%string-cmp "string<=?" string1 string2) 1))(define (string>=? string1 string2) "(string<? string1 string2) - -Function return true if second character is not smaller then the first one." (> (%string-cmp "string>=?" string1 string2) -1))(define (%string-ci-cmp name string1 string2) "(%string-ci-cmp name a b) - -Function compare two strings ingoring case and return 0 if they are equal, --1 second is smaller and 1 if is larget. The function compare -the codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (lower) (cmp (--> string2 (lower)))))(define (string-ci=? string1 string2) "(string-ci=? string1 string2) - -Function check if two string s are equal." (= (%string-ci-cmp "string-ci=?" string1 string2) 0))(define (string-ci<? string1 string2) "(string-ci<? string1 string2) - -Function return true if second string is smaller then the first one." (= (%string-ci-cmp "string-ci<?" string1 string2) -1))(define (string-ci>? string1 string2) "(string-ci<? string1 string2) - -Function return true if second string is larger then the first one." (= (%string-ci-cmp "string-ci>?" string1 string2) 1))(define (string-ci<=? string1 string2) "(string-ci<? string1 string2) - -Function return true if second string is not larger then the first one." (< (%string-ci-cmp "string-ci<=?" string1 string2) 1))(define (string-ci>=? string1 string2) "(string-ci>=? string1 string2) - -Function return true if second character is not smaller then the first one." (> (%string-ci-cmp "string-ci>=?" string1 string2) -1))(define char? (%doc "(char? obj) - -Function check if object is character." (curry instanceof lips.LCharacter)))(define (char->integer chr) "(char->integer chr) - -Function return codepoint of Unicode character." (typecheck "char->integer" chr "character") (--> chr.__char__ (codePointAt 0)))(define (integer->char n) "(integer->char chr) - -Function convert number argument to chararacter." (typecheck "integer->char" n "number") (if (integer? n) (string-ref (String.fromCodePoint n) 0) (throw "argument to integer->char need to be integer.")))(define-macro (%define-chr-re spec str re) "(%define-chr-re (name chr) sring re) - -Macro define procedure that test character agains regular expression." (quasiquote (define (unquote spec) (unquote str) (typecheck (unquote (symbol->string (car spec))) (unquote (cadr spec)) "character") (not (null? (--> chr (toString) (match (unquote re))))))))(%define-chr-re (char-whitespace? chr) "(char-whitespace? chr) - -Function return true if character is whitespace." (let-env (interaction-environment) (--> **internal-env** (get (quote space-unicode-regex)))))(%define-chr-re (char-numeric? chr) "(char-numeric? chr) - -Function return true if character is number." (let-env (interaction-environment) (--> **internal-env** (get (quote numeral-unicode-regex)))))(%define-chr-re (char-alphabetic? chr) "(char-alphabetic? chr) - -Function return true if character is leter of the ASCII alphabet." (let-env (interaction-environment) (--> **internal-env** (get (quote letter-unicode-regex)))))(define (%char-cmp name chr1 chr2) "(%char-cmp name a b) - -Function compare two characters and return 0 if they are equal, --1 second is smaller and 1 if is larget. The function compare -the codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (let ((a (char->integer chr1)) (b (char->integer chr2))) (cond ((= a b) 0) ((< a b) -1) (else 1))))(define (char=? chr1 chr2) "(char=? chr1 chr2) - -Function check if two characters are equal." (= (%char-cmp "char=?" chr1 chr2) 0))(define (char<? chr1 chr2) "(char<? chr1 chr2) - -Function return true if second character is smaller then the first one." (= (%char-cmp "char<?" chr1 chr2) -1))(define (char>? chr1 chr2) "(char<? chr1 chr2) - -Function return true if second character is larger then the first one." (= (%char-cmp "char>?" chr1 chr2) 1))(define (char<=? chr1 chr2) "(char<? chr1 chr2) - -Function return true if second character is not larger then the first one." (< (%char-cmp "char<=?" chr1 chr2) 1))(define (char>=? chr1 chr2) "(char<? chr1 chr2) - -Function return true if second character is not smaller then the first one." (> (%char-cmp "char>=?" chr1 chr2) -1))(define (%char-ci-cmp name chr1 chr2) "(%char-cmp name a b) - -Function compare two characters and return 0 if they are equal, --1 second is smaller and 1 if is larget. The function compare -the codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (%char-cmp name (char-downcase chr1) (char-downcase chr2)))(define (char-ci=? chr1 chr2) "(char-ci=? chr1 chr2) - -Function check if two characters are equal." (= (%char-ci-cmp "char-ci=?" chr1 chr2) 0))(define (char-ci<? chr1 chr2) "(char-ci<? chr1 chr2) - -Function return true if second character is smaller then the first one." (= (%char-ci-cmp "char-ci<?" chr1 chr2) -1))(define (char-ci>? chr1 chr2) "(char-ci<? chr1 chr2) - -Function return true if second character is larger then the first one." (= (%char-ci-cmp "char-ci>?" chr1 chr2) 1))(define (char-ci<=? chr1 chr2) "(char-ci<? chr1 chr2) - -Function return true if second character is not larger then the first one." (< (%char-ci-cmp "char-ci<=?" chr1 chr2) 1))(define (char-ci>=? chr1 chr2) "(char-ci<? chr1 chr2) - -Function return true if second character is not smaller then the first one." (> (%char-ci-cmp "char-ci>=?" chr1 chr2) -1))(define (char-upcase char) "(char-upcase char) - -Create uppercase version of the character." (typecheck "char-upcase" char "character") (char.toUpperCase))(define (char-downcase char) "(char-downcase chr) - -Create lowercase version of the character." (typecheck "char-upcase" char "character") (char.toLowerCase))(define (char-upper-case? char) "(char-upper-case? char) - -Function check if character is upper case." (typecheck "char-upper-case?" char "character") (and (char-alphabetic? char) (char=? (char-upcase char) char)))(define (char-lower-case? char) "(char-upper-case? char) - -Function check if character is lower case." (typecheck "char-lower-case?" char "character") (and (char-alphabetic? char) (char=? (char-downcase char) char)))(define (newline . rest) "(newline [port]) - -Write newline character to standard output or given port" (let ((port (if (null? rest) (current-output-port) (car rest)))) (display " -" port)))(define (write obj . rest) "(write obj [port]) - -Write object to standard output or give port. For strings it will include -wrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (display (repr obj #t) port)))(define (write-char char . rest) "(write-char char [port]) - -Write single character to given port using write function." (typecheck "write-char" char "character") (if (not (null? rest)) (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest)))(define fold-right reduce)(define fold-left fold)(define (make-vector n . rest) "(make-vector n [fill]) - -Create new vector with n empty elements. If fill is specified it will set -all elements of the vector to that value." (let ((result (new Array n))) (if (not (null? rest)) (--> result (fill (car rest))) result)))(define (vector? n) "(vector? n) - -Function return true of value is vector and false if not." (string=? (type n) "array"))(define (vector-ref vec n) "(vector-ref vec n) - -Function return nth element of the vector vec." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (. vec n))(define (vector-set! vec n value) "(vector-set! vec n value) - -Function set nth item of the vector to value." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (set-obj! vec n value))(define (vector-fill! vec value) "(vector-fill! vec value) - -Set every element of the vector to given value." (typecheck "vector-ref" vec "array") (let recur ((n (- (length vec) 1))) (if (>= n 0) (begin (set-obj! vec n value) (recur (- n 1))))))(define (vector-length vec) "(vector-length vec) - -Function return length of the vector. If argument is not vector it throw exception." (typecheck "vector-length" vec "array") (length vec))(define-syntax case (syntax-rules (else =>) ((case (key ...) clauses ...) (let ((atom-key (key ...))) (case atom-key clauses ...))) ((case key (else => result)) (result key)) ((case key (else result1 result2 ...)) (begin result1 result2 ...)) ((case key ((atoms ...) result1 result2 ...)) (if (memv key (quote (atoms ...))) (begin result1 result2 ...))) ((case key ((atoms ...) => result)) (if (memv key (quote (atoms ...))) (result key))) ((case key ((atoms ...) => result) clause clauses ...) (if (memv key (quote (atoms ...))) (result key) (case key clause clauses ...))) ((case key ((atoms ...) result1 result2 ...) clause clauses ...) (if (memv key (quote (atoms ...))) (begin result1 result2 ...) (case key clause clauses ...)))) "(case value - ((<items>) result1) - ((<items>) result2) - [else result3]) - -Macro for switch case statement. It test if value is any of the item. If -item match the value it will return coresponding result expression value. -If no value match and there is else it will return that result.")(--> lips.Formatter.defaults.exceptions.specials (push "case"))(define (numerator n) "(numerator n) - -Return numberator of rational or same number if n is not rational." (typecheck "numerator" n "number") (if (and (rational? n) (not (integer? n))) n.num n))(define (denominator n) "(denominator n) - -Return denominator of rational or same number if one is not rational." (typecheck "denominator" n "number") (if (and (rational? n) (not (integer? n))) n.denom (if (exact? n) 1 1.0)))(define (imag-part n) "(imag-part n) - -Return imaginary part of the complex number n." (typecheck "imag-part" n "number") (if (%number-type "complex" n) n.__im__ 0))(define (real-part n) "(real-part n) - -Return real part of the complex number n." (typecheck "real-part" n "number") (if (%number-type "complex" n) n.__re__ n))(define (make-polar r angle) "(make-polar magnitude angle) - -Create new complex number from polar parameters." (typecheck "make-polar" r "number") (typecheck "make-polar" angle "number") (if (or (complex? r) (complex? angle)) (error "make-polar: argument can't be complex") (let ((re (* r (sin angle))) (im (* r (cos angle)))) (make-rectangular im re))))(define (angle x) "(angle x) - -Returns angle of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__)))(define (magnitude x) "(magnitude x) - -Returns magnitude of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__)))))(define random (let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110)) (lambda new-seed "(random) -(random seed) - -Function generate new random real number using Knuth algorithm." (if (pair? new-seed) (set! seed (car new-seed)) (set! seed (modulo (+ (* seed a) c) m))) (exact->inexact (/ seed m)))))(define (eof-object? obj) "(eof-object? arg) - -Function check if value is eof object, returned from input string -port when there are no more data to read." (eq? obj eof))(define (output-port? obj) "(output-port? arg) - -Function return true if argument is output port." (instanceof lips.OutputPort obj))(define (input-port? obj) "(input-port? arg) - -Function return true if argument is input port." (instanceof lips.InputPort obj))(define (char-ready? . rest) "(char-ready?) -(char-ready? port) - -Function check it characters is ready in input port. This is usefull mostly -for interactive ports that return false if it would wait for user input. -It return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready)))(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename) - -Function return new Input Port with given filename. In Browser user need to -provide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename)))))))(define (close-input-port port) "(close-input-port port) - -Procedure close port that was opened with open-input-file. After that -it no longer accept reading from that port." (typecheck "close-input-port" port "input-port") (port.close))(define (close-output-port port) "(close-output-port port) - -Procedure close port that was opened with open-output-file. After that -it no longer accept write to that port." (typecheck "close-output-port" port "output-port") (port.close))(define (call-with-input-file filename proc) "(call-with-input-file filename proc) - -Procedure open file for reading, call user defined procedure with given port -and then close the port. It return value that was returned by user proc -and it close the port even if user proc throw exception." (let ((p (open-input-file filename))) (try (proc p) (finally (close-input-port p)))))(define (call-with-output-file filename proc) "(call-with-output-file filename proc) - -Procedure open file for writing, call user defined procedure with port -and then close the port. It return value that was returned by user proc and it close the port -even if user proc throw exception." (let ((p (open-output-file filename))) (try (proc p) (finally (close-output-port p)))))(define (with-input-from-file string thunk) "(with-input-from-file string thunk) - -Procedure open file and make it current-input-port then thunk is executed. -After thunk is executed current-input-port is restored and file port -is closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port)))))(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port)))))(define (file-exists? filename) (new Promise (lambda (resolve) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f)))))))))(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename) - -Function open file and return port that can be used for writing. If file -exists it will throw an Error." (typecheck "open-output-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w")))))))))(define (scheme-report-environment version) "(scheme-report-environment version) - -Function return new Environment object for given Scheme Spec version. -Only argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported"))))))(define-macro (%make-vector prefix type help) "(%make-vector prefix type help) - -Mega helper macro that create list of functions for single byte vector -based on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...) - -Create ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v) - -return length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a v1 v2 ...) - -Allocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x) - -Function return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k) - -Function test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k) - -Function return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k) - -Function set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote))))))))(%make-vector u8 Uint8Array "usigned 8-bit integer vector")(%make-vector s8 Int8Array "signed 8-bit integer vector")(%make-vector u16 Uint16Array "usigned 16-bit integer vector")(%make-vector s16 Int16Array "signed 16-bit integer vector")(%make-vector u32 Uint16Array "usigned 32-bit integer vector")(%make-vector s32 Int16Array "signed 32-bit integer vector")(%make-vector f32 Float32Array "32-bit IEEE floating point number vector")(%make-vector f64 Float64Array "64-bit IEEE floating point number vector")(define (list-match? predicate list) "(list-match? predicate list) - -Function check if consecutive elements of the list match the predicate function." (typecheck "list-match?" predicate #("function" "macro")) (typecheck "list-match?" list "pair") (or (or (null? list) (null? (cdr list))) (and (predicate (car list) (cadr list)) (list-match? predicate (cdr list)))))(define (symbol=? . args) "(symbol=? s1 s2 ...) - -Function check if each value is symbol and it's the same acording to string=? predicate." (list-match? (lambda (a b) (and (symbol? a) (symbol? b) (equal? a b))) args))(define (values-ref values n) "(values-ref values n) - -Function return n value of values object which is result of value function." (typecheck "values-ref" values "values" 1) (typecheck "values-ref" n "number" 1) (--> values (valueOf) n))(define-syntax let-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ (((x ...) values) ...) body ...) (apply (lambda (x ... ...) body ...) (vector->list (apply vector-append (map (lambda (x) ((. x "valueOf"))) (list values ...))))))) "(let-values binding body ...) - -The macro work similar to let but variable is list of values and value -need to evaluate to result of calling values.")(define (vector-append . args) "(vector-append v1 v2 ...) - -Function return new vector by combining it's arguments that should be vectors." (if (null? args) (vector) (begin (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args)))))))(define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...) - -The macro work similar to let* but variable is list of values and value -need to evaluate to result of calling values.")(define (quotient&remainder x y) (values (quotient x y) (remainder x y)))(define (floor/ x y) (let ((q (quotient x y)) (r (remainder x y))) (if (>= x 0) (if (or (> y 0) (zero? r)) (values q r) (values (- q 1) (+ r y))) (if (and (> y 0) (not (zero? r))) (values (- q 1) (+ r y)) (values q r)))))(define (floor-quotient x y) (values-ref (floor/ x y) 0))(define (floor-remainder x y) (modulo x y))(define (truncate/ x y) (quotient&remainder x y))(define (truncate-quotient x y) (quotient x y))(define (truncate-remainder x y) (remainder x y))(define-syntax case-lambda (syntax-rules () ((case-lambda (params body0 ...) ...) (lambda args (let ((len (length args))) (letrec-syntax ((cl (syntax-rules ::: () ((cl) (error "no matching clause")) ((cl ((p :::) . body) . rest) (if (= len (length (quote (p :::)))) (apply (lambda (p :::) . body) args) (cl . rest))) ((cl ((p ::: . tail) . body) . rest) (if (>= len (length (quote (p :::)))) (apply (lambda (p ::: . tail) . body) args) (cl . rest)))))) (cl (params body0 ...) ...)))))) "(case-lambda expr ...) - -Macro create new function with different version of the function depend on -number of arguments. Each expression is similar to single lambda. - -e.g.: - - (define sum - (case-lambda - ((x) x) - ((x y) (+ x y)) - ((x y z) (+ x y z)))) - - (sum 1) - (sum 1 2) - (sum 1 2 3) - -More arguments will give error.")(define (boolean=? . args) "(boolean=? b1 b2 ...) - -Function check if all arguments are boolean and if they are the same." (if (< (length args) 2) (error "boolean=?: too few arguments") (reduce (lambda (acc item) (and (boolean? item) (eq? acc item))) (car args) (cdr args))))(define (port? x) "(port? x) - -Function return true of argumet is nput or output port port object." (or (output-port? x) (input-port? x)))(define (square x) "(square z) - -Returns the square of z. This is equivalent to (* z z)." (* x x))(define-syntax when (syntax-rules () ((when test result1 result2 ...) (if test (begin result1 result2 ...)))) "(when test body ...) - -Macro execute body when test expression is true.")(define-syntax unless (syntax-rules () ((unless test result1 result2 ...) (if (not test) (begin result1 result2 ...)))) "(unless test body ...) - -Macro execute body when test expression is false.")(define inexact exact->inexact)(define exact inexact->exact)(define (exact-integer? n) "(exact-integer? n) - -Function returns #t if z is both exact and an integer; otherwise -returns #f." (and (integer? n) (exact? n)))(define (string->vector s) "(string->vector string) - -Function return vector of characters created from string." (typecheck "string->list" s "string") (--> s (split "") (map (lambda (x) (lips.LCharacter x)))))(define (vector->string v) "(vector->string vector) - -Function return new string created from vector of characters." (typecheck "vector->list" v "array") (--> v (map (lambda (char) (char.valueOf))) (join "")))(define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...) - -Function return new vector from applying function fn to each element -of the vectors, similar to map for lists." (if (or (= (length rest) 0) (not (every vector? rest))) (error "vector-map: function require at least 1 vector") (let ((len (apply min (map vector-length rest))) (result (vector))) (do ((i 0 (+ i 1))) ((= i len) result) (let* ((args (map (lambda (v) (vector-ref v i)) rest)) (value (apply fn args))) (--> result (push value)))))))(define (string-map fn . rest) "(string-map fn string1 stringr2 ...) - -Function return new string from applying function fn to each element -of the strings, similar to map for lists." (if (or (= (length rest) 0) (not (every string? rest))) (error "string-map: function require at least 1 string") (vector->string (apply vector-map fn (map string->vector rest)))))(define (dynamic-wind before thunk after) "(dynamic-wind before thunk after) - -Function accept 3 procedures/lambdas and execute thunk with before and always -after even if error accur" (before) (let ((result (try (thunk) (catch (e) (error e))))) (after) result))(define (with-exception-handler handler thunk) "(with-exception-handler handler thunk) - -Procedure call and return value of thunk function, if exception happen -it call handler procedure." (try (thunk) (catch (e) (handler e))))(define raise throw)(define-syntax define-values (syntax-rules () ((define-values () expr) (define dummy (call-with-values (lambda () expr) (lambda args #f)))) ((define-values (var) expr) (define var expr)) ((define-values (var0 var1 ... varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cadr var0))) (set! var0 (car var0)) v)))) ((define-values (var0 var1 ... . varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cdr var0))) (set! var0 (car var0)) v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) list)))) "(define-values (a b ...) expr) - -Function evaluate expression expr and if it evaluates to result of values -then it will defined each value as variable like with define.")(define-macro (include . files) "(include file ...) - -Macro that load at least one file content and insert them into one, -body expression." (if (null? files) (throw (new Error "include: at least one file path required")) (let ((result (vector)) (env (interaction-environment))) (if (eq? self global) (let* ((fs (require "fs")) (readFile (lambda (file) (new Promise (lambda (resolve reject) (fs.readFile file (lambda (err data) (if (null? err) (resolve (--> data (toString))) (reject err))))))))) (for-each (lambda (file) (let* ((expr (lips.parse (readFile file) env))) (set! result (--> result (concat expr))))) files)) (for-each (lambda (file) (let* ((text (--> (fetch file) (text))) (expr (lips.parse text env))) (set! result (--> result (concat expr))))) files)) (if (> result.length 0) (quasiquote (begin (unquote-splicing (vector->list result))))))))(define-syntax syntax-error (syntax-rules () ((_ "step" arg ...) (join " " (vector->list (vector (repr arg) ...)))) ((_ message arg ...) (raise (new Error (format "~a ~a" message (_ "step" arg ...)))))))(define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...))))(define (features) (quote (r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower)))(define *zero-number-chars* #(48 1632 1776 1984 2406 2534 2662 2790 2918 3046 3174 3302 3430 3558 3664 3792 3872 4160 4240 6112 6160 6470 6608 6784 6800 6992 7088 7232 7248 42528 43216 43264 43472 43504 43600 44016 65296 66720 68912 69734 69872 69942 70096 70384 70736 70864 71248 71360 71472 71904 72016 72784 73040 73120 92768 93008 120782 120792 120802 120812 120822 123200 123632 125264 130032))(define (digit-value chr) "(digit-value chr) - -Return digit number if character is numeral (as per char-numeric?) -or #f otherwise." (typecheck "digit-value" chr "character") (if (char-numeric? chr) (let ((ord (char->integer chr))) (do ((i (vector-length *zero-number-chars*) (- i 1)) (found #f) (result #f)) ((or (zero? i) found) result) (let* ((zero (vector-ref *zero-number-chars* (- i 1))) (diff (- ord zero))) (if (and (>= diff 0) (<= diff 9)) (begin (set! result diff) (set! found #t)))))) #f))(define make-bytevector make-u8vector)(define bytevector u8vector)(define bytevector? u8vector?)(define bytevector-length u8vector-length)(define bytevector-u8-ref u8vector-ref)(define bytevector-u8-set! u8vector-set!)(define (bytevector-append v1 . rest) "(bytevector-append v1 ...) - -Create new bytevector u8vector that is created from joining each argument." (typecheck "bytevector-append" v1 "uint8array" 1) (map (lambda (arg) (typecheck "bytevector-append" arg "uint8array")) rest) (if (null? rest) v1 (new Uint8Array (apply vector-append (Array.from v1) (map Array.from rest)))))(define (bytevector-copy v . rest) "(bytevector-copy v) -(bytevector-copy v start) -(bytevector-copy v start end) - -Function and return new vector from start to end. If no start and end is provided -whole vector is copied and returned." (if (null? rest) (new Uint8Array v) (let ((start (car rest))) (if (null? (cdr rest)) (v.slice start) (v.slice start (cadr rest))))))(define (bytevector-copy! to at from . rest) "(bytevector-copy! to at from) -(bytevector-copy! to at from start) -(bytevector-copy! to at from start end) - -Copies the bytes of bytevector from between start and end to bytevector to, -starting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1))))))(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) "(string->utf8 string) -(string->utf8 string start) -(string->utf8 string start end) - -Function converts string into u8 bytevector using utf8 encoding. -The start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end)))))))(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector) -(utf8->string u8vector start) -(utf8->string u8vector start end) - -Function converts u8 bytevector into string using utf8 encoding. -The start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end)))))))(define (open-input-string string) "(open-input-string string) - -Function create new string port as input that can be used to -read S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment)))(define (open-output-string) "(open-output-string) - -Function create new output port that can used to write string into -and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr))(define (get-output-string port) "(get-output-string port) - -Function get full string from string port. If nothing was wrote -to given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString)))(define (open-input-bytevector bytevector) "(open-input-bytevector bytevector) - -Create new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector))(define (open-binary-input-file filename) "(open-binary-input-file filename) - -Function return new Input Binary Port with given filename. In Browser -user need to provide global fs variable that is instance of FS interface." (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) (new lips.InputBinaryFilePort u8vector filename)))(define (binary-port? port) "(binary-port? port) - -Function test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary"))))(define (textual-port? port) "(textual-port? port) - -Function test if argument is string port." (and (port? port) (eq? port.__type__ (Symbol.for "text"))))(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port. Binary port required."))) ((unquote fn) (unquote port))))))))(%define-binary-input-lambda peek-u8 "(peek-u8) -(peek-u8 port) - -Return next byte from input-binary port. If there are no more bytes -it return eof object." (lambda (port) (port.peek_u8)))(%define-binary-input-lambda read-u8 "(read-u8) -(read-u8 port) - -Read next byte from input-binary port. If there are no more bytes -it return eof object." (lambda (port) (port.read_u8)))(%define-binary-input-lambda u8-ready? "(u8-ready?) -(u8-ready? port) - -Returns #t if a byte is ready on the binary input port and returns #f otherwise. -If u8-ready? returns #t then the next read-u8 operation on the given port is -guaranteed not to hang. If the port is at end of file then u8-ready? returns #t." (lambda (port) (port.u8_ready)))(define (read-bytevector k . rest) "(read-bytevector k) -(read-bytevector k port) - -Read next n bytes from input-binary port. If there are no more bytes -it returns eof object. If there are less then n bytes in port it -return the only bytes that are available" (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-bytevector" port "input-port") (if (not (binary-port? port)) (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k))))(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename) - -Function delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename)))))))(define (call-with-port port proc) "(call-with-port port proc) - -Proc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close)))))(define (close-port port) "(close-port port) - -Close input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close))(define (eof-object) "(eof-object) - -Procedure returns eof object that indicate end of the port" lips.eof)(define (output-port-open? port) "(output-port-open? port) - -Function check if argument is output-port and if you can write to it." (and (output-port? port) (port.is_open)))(define (input-port-open? port) "(input-port-open? port) - -Function check if argument is input-port and if you can read from it." (and (input-port? port) (port.is_open)))(define (flush-output-port port) "(flush-output-port port) - -Functio do nothing, flush is not needed in LIPS in both NodeJS and Browser. -The function is added, so it don't throw exception when using R7RS code." (if #f #f))(define (write-string string . rest) "(write-string string) -(write-string string port) -(write-string string port start) -(write-string string port start end) - -Writes the characters of string from start to end in left-toright order -to the textual output port." (typecheck "write-string" string "string") (let ((port (if (null? rest) (current-output-port) (car rest))) (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) (string-length string) (caddr rest)))) (typecheck "write-string" port "output-port") (typecheck "write-string" start "number") (typecheck "write-string" end "number") (display (substring string start end) port)))(define (write-char char . rest) "(write-char string) -(write-char string port) - -Writes the character char (not an external representation of the character) -to the given textual output port and returns an unspecified value." (typecheck "write-char" char "character") (let ((port (if (null? rest) (current-output-port) (car rest)))) (typecheck "write-char" port "output-port") (display (string char) port)))(define (read-string k . rest) "(read-string k) -(read-string k port) - -Reads the next k characters, or as many as are available -before the end of file, from the textual input port into a -newly allocated string in left-to-right order and returns the -string. If no characters are available before the end of file, -an end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k)))(define (list-copy obj) "(list-copy obj) - -Copy the object passed as argument but only if it's list. The car elements -of the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f)))(define-macro (define-record-type name constructor pred . fields) "(define-record-type name constructor pred . fields) - -Macro for defining records. Example of usage: - - (define-record-type <pare> - (kons x y) - pare? - (x kar set-kar!) - (y kdr set-kdr!)) - -(define p (kons 1 2)) -(print (kar p)) -;; 1 -(set-kdr! p 3) -(print (kdr p)) -;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields))))))(define (nan? x) "(nan? x) - -Function check if argument x is Not a Number (NaN) value." (and (number? x) (or (x.isNaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x)))))))(define (infinite? x) "(infinite? x) - -Function check if value is infinite." (or (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (number? x) (not (eq? x NaN)) (%number-type "complex" x) (or (infinite? (real-part x)) (infinite? (imag-part x))))))(define (finite? x) "(finite? x) - -Function check if value is finite." (not (infinite? x)))(define-class %Library Object (constructor (lambda (self name) (set! self.__namespace__ &()) (set! self.__name__ name))) (append (lambda (self namespace env) (if (environment? (. self.__namespace__ namespace)) (throw (new Error (string-append "namespace " namespace " already exists in library " self.__name__))) (set-obj! self.__namespace__ namespace env)))) (env (lambda (self namespace) (let ((env (. self.__namespace__ namespace))) (if (not (environment? env)) (throw (new Error (string-append "namespace " namespace " sdon't exists"))) env)))) (get (lambda (self namespace name) (--> (self.env namespace) (get name)))) (set (lambda (self namespace name value) (--> (self.env namespace) (set name value)))) (toString (lambda (self) (string-append "#<Library(" self.__name__ ")>"))))(define (%import-name library namespace names) (quasiquote (begin (unquote-splicing (map (lambda (name) (quasiquote (define (unquote name) (--> (unquote library) (get (quote (unquote namespace)) (quote (unquote name))))))) names)))))(define-macro (import . specs) "(import (library namespace)) -(import (only (library namespace) name1 name2)) - -Macro for importing names from library." (let ((parent (current-environment))) (quasiquote (begin (unquote-splicing (map (lambda (spec) (if (not (pair? spec)) (throw (new Error "import: invalid syntax")) (cond ((symbol=? (car spec) (quote only)) (let ((lib (caadr spec)) (namespace (caaddr spec))) (if (pair? (cadr spec)) (%import-name (unquote lib) (quote (unquote namespace)) (quote (unquote (caddr spec)))) (throw (new Error "import: invalid syntax"))))) (else (let* ((lib-name (car spec)) (lib (parent.get lib-name)) (namespace (cadr spec))) (%import-name lib-name namespace (env (lib.env namespace)))))))) specs))))))(define (new-library name namespace) "(new-library name) - -Create new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib))(define (%export module namespace specs) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) specs)))))(define-macro (define-library spec . body) "(define-library (library (name namespace) . body) - -Macro for defining modules inside you can use define to create functions. -And use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var)))))))(define-values (current-directory set-current-directory!) (if (eq? self window) (let ((cwd (string-append location.origin (--> location.pathname (replace #/\/[^/]+$/ "/"))))) (values (lambda () "(current-directory) - -Return corrent working directory, default it's corrent URL." cwd) (lambda (value) "(set-current-directory! string) - -Function change current working directory to provided string." (typecheck "set-current-directory!" value "string") (set! cwd value)))) (let ((process (require "process"))) (values (lambda () "(current-directory) - -Return corrent working directory, default it's path from where -the script was executed." (string-append (process.cwd) "/")) (lambda (value) "(set-current-directory! string) - -Function change current working directory to provided string." (typecheck "set-current-directory!" value "string") (process.chdir value)))))) \ No newline at end of file +(define (%doc string fn) (typecheck "%doc" fn "function") (typecheck "%doc" string "string") (set-obj! fn (quote __doc__) (--> string (replace #/^ +/gm ""))) fn) +(define-macro (let-syntax vars . body) "(let-syntax ((name fn)) body)\u000A\u000A Macro works like combination of let and define-syntax. It creaates\u000A local macros and evaluate body in context of those macros.\u000A The macro to letrec-syntax is like letrec is to let." (quasiquote (let (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "let-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body)))) +(define-macro (letrec-syntax vars . body) "(letrec-syntax ((name fn)) body)\u000A\u000A Macro works like combination of letrec and define-syntax. It creaates\u000A local macros and evaluate body in context of those macros." (quasiquote (letrec (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "letrec-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body)))) +(define-macro (define-syntax name expr . rest) "(define-syntax name expression [__doc__])\u000A\u000AMacro define new hygienic macro using syntax-rules with optional documentation" (let ((expr-name (gensym "expr-name"))) (quasiquote (define (unquote name) (let (((unquote expr-name) (unquote expr))) (typecheck "define-syntax" (unquote expr-name) "syntax") (unquote expr-name)) (unquote-splicing rest))))) +(define (quoted-symbol? x) "(quoted-symbol? code)\u000A\u000AHelper function that test if value is quoted symbol. To be used in macros\u000Athat pass literal code that is transformed by parser.\u000A\u000Ausage:\u000A\u000A (define-macro (test x)\u000A (if (quoted-symbol? x)\u000A `',(cadr x)))\u000A\u000A (list 'hello (test 'world))" (and (pair? x) (eq? (car x) (quote quote)) (symbol? (cadr x)) (null? (cddr x)))) +(define-macro (--> expr . code) "Helper macro that simplify calling methods on objects. It work with chaining\u000A\u000Ausage: (--> ($ \"body\")\u000A (css \"color\" \"red\")\u000A (on \"click\" (lambda () (display \"click\"))))\u000A\u000A (--> document (querySelectorAll \"div\"))\u000A (--> (fetch \"https://jcubic.pl\")\u000A (text)\u000A (match #/<title>([^<]+)<\\/title>/)\u000A 1)\u000A (--> document\u000A (querySelectorAll \".cmd-prompt\")\u000A 0\u000A \"innerText\")\u000A (--> document.body\u000A (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) (quasiquote (let* (((unquote obj) (unquote expr))) (unquote-splicing (map (lambda (code) (let ((value (gensym "value"))) (quasiquote (let* (((unquote value) (unquote (let ((name (cond ((quoted-symbol? code) (symbol->string (cadr code))) ((pair? code) (symbol->string (car code))) (#t code)))) (if (string? name) (quasiquote (. (unquote obj) (unquote-splicing (split "." name)))) (quasiquote (. (unquote obj) (unquote name)))))))) (unquote (if (and (pair? code) (not (quoted-symbol? code))) (quasiquote (set! (unquote obj) ((unquote value) (unquote-splicing (cdr code))))) (quasiquote (set! (unquote obj) (unquote value))))))))) code)) (unquote obj))))) +(define-macro (define-global first . rest) "(define-global var value)\u000A(define-global (name . args) body)\u000A\u000AMacro that define functions or variables in global context, so they can be used\u000Ainside let and get let variables in closure, Useful for universal macros." (if (pair? first) (let ((name (car first))) (quasiquote (--> lips.env (set (unquote (symbol->string name)) (lambda (unquote (cdr first)) (unquote-splicing rest)))))) (quasiquote (--> lips.env (set (unquote (symbol->string first)) (unquote (car rest))))))) +(define-macro (globalize expr . rest) "(globalize expr)\u000A\u000A Macro will get the value of the expression and add each method as function to global\u000A scope." (let* ((env (current-environment)) (obj (eval expr env)) (name (gensym "name")) (env-name (gensym "env-name")) (make-name (if (pair? rest) (let ((pre (symbol->string (car rest)))) (lambda (name) (string->symbol (concat pre name)))) string->symbol))) (quasiquote (let (((unquote name) (unquote expr))) (unquote-splicing (filter pair? (map (lambda (key) (if (and (not (match /^_/ key)) (function? (. obj key))) (let* ((args (gensym "args"))) (quasiquote (define-global ((unquote (make-name key)) unquote args) (apply (. (unquote name) (unquote key)) (unquote args))))))) (array->list (--> Object (keys obj)))))))))) +(define (single list) "(single list)\u000A\u000AFunction check if argument is list with single element" (and (pair? list) (not (cdr list)))) +(define (iterator? x) "(iterator? x)\u000A\u000A Function check if value is JavaScript iterator object" (and (object? x) (procedure? (. x Symbol.iterator)))) +(define-macro (.. expr) "(.. foo.bar.baz)\u000A\u000AMacro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts)))))))) +(set-special! "#:" (quote gensym-interal) lips.specials.LITERAL) +(define (gensym-interal symbol) "(gensym-interal symbol)\u000A\u000AParser extension that create new quoted named gensym." (quasiquote (quote (unquote (gensym symbol))))) +(define (plain-object? x) "(plain-object? x)\u000A\u000AFunction check if value is plain JavaScript object. Created using object macro." (and (== (--> (type x) (cmp "object")) 0) (eq? (. x (quote constructor)) Object))) +(define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o)\u000A\u000AFunction test if argumnet is JavaScript typed array (Scheme byte vector)." (instanceof TypedArray o)))) +(define (symbol->string s) "(symbol->string symbol)\u000A\u000AFunction convert LIPS symbol to string." (if (symbol? s) (let ((name s.__name__)) (if (string? name) name (--> name (toString)))))) +(define (string->symbol string) "(string->symbol string)\u000A\u000AFunction convert string to LIPS symbol." (and (string? string) (%as.data (new (. lips "LSymbol") string)))) +(define (alist->object alist) "(alist->object alist)\u000A\u000AFunction convert alist pairs to JavaScript object." (if (pair? alist) (alist.toObject) (alist->object (new lips.Pair undefined ())))) +(define (parent.frames) "(parent.frames)\u000A\u000AFuncion return list of environments from parent frames (lambda function calls)" (let iter ((result (quote ())) (frame (parent.frame 1))) (if (eq? frame (interaction-environment)) (cons frame result) (if (null? frame) result (let ((parent.frame (--> frame (get (quote parent.frame) (object :throwError #f))))) (if (function? parent.frame) (iter (cons frame result) (parent.frame 0)) result)))))) +(define-macro (wait time . expr) "(wait time . expr)\u000A\u000AFunction return promise that will resolve with evaluating the expression after delay." (quasiquote (promise (timer (unquote time) (resolve (begin (unquote-splicing expr))))))) +(define (pair-map fn seq-list) "(pair-map fn list)\u000A\u000AFunction call fn argument for pairs in a list and return combined list with\u000Avalues returned from function fn. It work like the map but take two items from list" (let iter ((seq-list seq-list) (result (quote ()))) (if (null? seq-list) result (if (and (pair? seq-list) (pair? (cdr seq-list))) (let* ((first (car seq-list)) (second (cadr seq-list)) (value (fn first second))) (if (null? value) (iter (cddr seq-list) result) (iter (cddr seq-list) (cons value result)))))))) +(define (object-expander readonly expr . rest) "(object-expander reaonly '(:foo (:bar 10) (:baz (1 2 3))))\u000A\u000ARecursive function helper for defining LIPS code for create objects\u000Ausing key like syntax." (let ((name (gensym "name")) (quot (if (null? rest) #f (car rest)))) (if (null? expr) (quasiquote (alist->object ())) (quasiquote (let (((unquote name) (alist->object (quote ())))) (unquote-splicing (pair-map (lambda (key value) (if (not (key? key)) (let ((msg (string-append (type key) " " (repr key) " is not a symbol!"))) (throw msg)) (let ((prop (key->string key))) (if (and (pair? value) (key? (car value))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote (object-expander readonly value)))) (if quot (quasiquote (set-obj! (unquote name) (unquote prop) (quote (unquote value)))) (quasiquote (set-obj! (unquote name) (unquote prop) (unquote value)))))))) expr)) (unquote (if readonly (quasiquote (Object.freeze (unquote name))))) (unquote name)))))) +(define-macro (object . expr) "(object :name value)\u000A\u000AMacro that create JavaScript object using key like syntax." (try (object-expander #f expr) (catch (e) (error e.message)))) +(define-macro (object-literal . expr) "(object-literal :name value)\u000A\u000AMacro that create JavaScript object using key like syntax. This is similar,\u000Ato object but all values are quoted. This macro is used with & object literal." (try (object-expander #t expr #t) (catch (e) (error e.message)))) +(define (alist->assign desc . sources) "(alist->assign alist . list-of-alists)\u000A\u000AFunction that work like Object.assign but for LIPS alist." (for-each (lambda (source) (for-each (lambda (pair) (let* ((key (car pair)) (value (cdr pair)) (d-pair (assoc key desc))) (if (pair? d-pair) (set-cdr! d-pair value) (append! desc (list pair))))) source)) sources) desc) +(define (key? symbol) "(key? symbol)\u000A\u000AFunction check if symbol is key symbol, have colon as first character." (and (symbol? symbol) (== (--> (substring (symbol->string symbol) 0 1) (cmp ":")) 0))) +(define (key->string symbol) "(key->string symbol)\u000A\u000AIf symbol is key it convert that to string - remove colon." (if (key? symbol) (substring (symbol->string symbol) 1))) +(define (%as.data obj) "(%as.data obj)\u000A\u000AMark object as data to stop evaluation." (if (object? obj) (begin (set-obj! obj (quote data) #t) obj))) +(define (%hidden-props obj) "(%hidden-props obj)\u000A\u000AFunction return hidden names of an object, for ES6 class prototype\u000Ait return all methods since they are indistinguishable from hidden property\u000Acreated using defineProperty." (let* ((descriptors (Object.getOwnPropertyDescriptors obj)) (names (Object.keys descriptors))) (--> names (filter (lambda (name) (let ((descriptor (. descriptors name))) (eq? descriptor.enumerable #f))))))) +(define (dir obj . rest) "(dir obj)\u000A\u000AFunction return all props on the object including those in prototype chain." (if (or (null? obj) (eq? obj Object.prototype)) () (let ((proto (if (null? rest) #f (car rest))) (names (Object.getOwnPropertyNames obj))) (if (not proto) (let ((hidden (%hidden-props obj))) (set! names (--> names (filter (lambda (name) (not (hidden.includes name)))))))) (append (array->list (--> names (map (unary string->symbol)))) (dir (Object.getPrototypeOf obj) #t))))) +(define (tree-map f tree) "(tree-map fn tree)\u000A\u000ATree version of map. Function is invoked on every leaf." (if (pair? tree) (cons (tree-map f (car tree)) (tree-map f (cdr tree))) (f tree))) +(define (native.number x) "(native.number obj)\u000A\u000AIf argument is number it will convert to native number." (if (number? x) (value x) x)) +(define (value obj) "(value obj)\u000A\u000AFunction unwrap LNumbers and convert nil value to undefined." (if (eq? obj ()) undefined (if (number? obj) ((. obj "valueOf")) obj))) +(define-macro (define-formatter-rule . patterns) "(rule-pattern pattern)\u000A\u000AAnaphoric Macro for defining patterns for formatter. With Ahead, Pattern and * defined values." (let ((rules (gensym "rules"))) (quasiquote (let (((unquote rules) lips.Formatter.rules) (Ahead (lambda (pattern) (let ((Ahead (.. lips.Formatter.Ahead))) (new Ahead (if (string? pattern) (new RegExp pattern) pattern))))) (* (Symbol.for "*")) (Pattern (lambda (pattern flag) (new lips.Formatter.Pattern (list->array pattern) (if (null? flag) undefined flag))))) (unquote-splicing (map (lambda (pattern) (quasiquote (--> (unquote rules) (push (tree->array (tree-map native.number (unquote-splicing pattern))))))) patterns)))))) +(define-syntax cond (syntax-rules (=> else) ((cond (else else1 else2 ...)) (if #t (begin else1 else2 ...))) ((cond (test => receiver) more-clause ...) (let ((t test)) (cond/maybe-more t (receiver t) more-clause ...))) ((cond (generator guard => receiver) more-clause ...) (call-with-values (lambda () generator) (lambda t (cond/maybe-more (apply guard t) (apply receiver t) more-clause ...)))) ((cond (test) more-clause ...) (let ((t test)) (cond/maybe-more t t more-clause ...))) ((cond (test body1 body2 ...) more-clause ...) (cond/maybe-more test (begin body1 body2 ...) more-clause ...))) "(cond (predicate? . body)\u000A (predicate? . body)\u000A (else . body))\u000A\u000AMacro for condition checks. For usage instead of nested ifs.") +(define-syntax cond/maybe-more (syntax-rules () ((cond/maybe-more test consequent) (if test consequent)) ((cond/maybe-more test consequent clause ...) (if test consequent (cond clause ...)))) "(cond/maybe-more test consequent ...)\u000A\u000AHelper macro used by cond.") +(define-macro (cond . list) "(cond (predicate? . body)\u000A (predicate? . body))\u000AMacro for condition check. For usage instead of nested ifs." (if (pair? list) (let* ((item (car list)) (first (car item)) (forms (cdr item)) (rest (cdr list))) (quasiquote (if (unquote first) (begin (unquote-splicing forms)) (unquote (if (and (pair? rest) (or (eq? (caar rest) #t) (eq? (caar rest) (quote else)))) (quasiquote (begin (unquote-splicing (cdar rest)))) (if (not (null? rest)) (quasiquote (cond (unquote-splicing rest))))))))) ())) +(define (%r re . rest) "(%r re)\u000A\u000ACreate new regular expression from string, to not break Emacs formatting" (if (null? rest) (new RegExp re) (new RegExp re (car rest)))) +(define (interaction-environment) "(interaction-environment)\u000A\u000AFunction return interaction environement equal to lips.env can be overwritten,\u000Awhen creating new interpreter with lips.Interpreter." **interaction-environment**) +(define (current-output-port) "(current-output-port)\u000A\u000AFunction return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdout))))) +(define (current-error-port) "(current-output-port)\u000A\u000AFunction return default stdout port." (let-env (interaction-environment) (--> **internal-env** (get (quote stderr))))) +(define (current-input-port) "current-input-port)\u000A\u000AFunction return default stdin port." (let-env (interaction-environment) (--> **internal-env** (get (quote stdin))))) +(define (regex? x) "(regex? x)\u000A\u000AFunction return true of value is regular expression, it return false otherwise." (== (--> (type x) (cmp "regex")) 0)) +(define (set-repr! type fn) "(add-repr! type fn)\u000A\u000AFunction add string represention to the type, which should be constructor function.\u000A\u000AFunction fn should have args (obj q) and it should return string, obj is vlaue that\u000Aneed to be converted to string, if the object is nested and you need to use `repr`,\u000Ait should pass second parameter q to repr, so string will be quoted when it's true.\u000A\u000Ae.g.: (lambda (obj q) (string-append \"<\" (repr obj q) \">\"))" (typecheck "add-repr!" type "function") (typecheck "add-repr!" fn "function") (ignore (--> lips.repr (set type fn)))) +(define (unset-repr! type) "(unset-repr! type)\u000A\u000AFunction remove string represention to the type, which should be constructor function,\u000Aadded by add-repr! function." (typecheck "unset-repr!" type "function") (ignore (--> lips.repr (delete type)))) +(set-special! "&" (quote object-literal) lips.specials.SPLICE) +(set-repr! Object (lambda (x q) (concat "&(" (--> (Object.getOwnPropertyNames x) (map (lambda (key) (concat ":" key " " (repr (. x key) q)))) (join " ")) ")"))) +(define (bound? x . rest) "(bound? x [env])\u000A\u000AFunction check if variable is defined in given environement or interaction environment\u000Aif not specified." (let ((env (if (null? rest) (interaction-environment) (car rest)))) (try (begin (--> env (get x)) #t) (catch (e) #f)))) +(define (environment-bound? env x) "(environment-bound? env symbol)\u000A\u000AFunction check if symbol is bound variable similar to bound?." (typecheck "environment-bound?" env "environment" 1) (typecheck "environment-bound?" x "symbol" 2) (bound? x env)) +(define (qsort e predicate) "(qsort list predicate)\u000A\u000ASort the list using quick sort alorithm according to predicate." (if (or (null? e) (<= (length e) 1)) e (let loop ((left ()) (right ()) (pivot (car e)) (rest (cdr e))) (if (null? rest) (append (append (qsort left predicate) (list pivot)) (qsort right predicate)) (if (predicate (car rest) pivot) (loop (append left (list (car rest))) right pivot (cdr rest)) (loop left (append right (list (car rest))) pivot (cdr rest))))))) +(define (sort list . rest) "(sort list [predicate])\u000A\u000ASort the list using optional predicate function. if not function is specified\u000Ait will use <= and sort in increasing order." (let ((predicate (if (null? rest) <= (car rest)))) (typecheck "sort" list "pair") (typecheck "sort" predicate "function") (qsort list predicate))) +(define (every fn list) "(every fn list)\u000A\u000AFunction call function fn on each item of the list, if every value is true\u000Ait will return true otherwise it return false." (if (null? list) #t (and (fn (car list)) (every fn (cdr list))))) +(define (zip . args) "(zip list1 list2 ...)\u000A\u000ACreate one list by taking each element of each list." (if (null? args) () (if (some null? args) () (cons (map car args) (apply zip (map cdr args)))))) +(define-macro (promise . body) "(promise . body)\u000A\u000AAnaphoric macro that expose resolve and reject functions from JS promise" (quasiquote (new Promise (lambda (resolve reject) (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message)))))))) +(define-macro (timer time . body) "(timer time . body)\u000A\u000AMacro evaluate expression after delay, it return timer. To clear the timer you can use\u000Anative JS clearTimeout function." (quasiquote (setTimeout (lambda () (try (begin (unquote-splicing body)) (catch (e) (error (.. e.message))))) (unquote time)))) +(define (defmacro? obj) "(defmacro? expression)\u000A\u000AFunction check if object is macro and it's expandable." (and (macro? obj) (. obj (quote defmacro)))) +(define (n-ary n fn) "(n-ary n fn)\u000A\u000AReturn new function that limit number of arguments to n." (lambda args (apply fn (take n args)))) +(define (take n lst) "(take n list)\u000A\u000AReturn n first values of the list." (let iter ((result (quote ())) (i n) (lst lst)) (if (or (null? lst) (<= i 0)) (reverse result) (iter (cons (car lst) result) (- i 1) (cdr lst))))) +(define unary (%doc "(unary fn)\u000A\u000AFunction return new function with arguments limited to one." (curry n-ary 1))) +(define binary (%doc "(binary fn)\u000A\u000AFunction return new function with arguments limited to two." (curry n-ary 2))) +(define (%class-lambda expr) "(class-lambda expr)\u000A\u000AReturn lambda expression where input expression lambda have `this` as first argument." (let ((args (gensym (quote args)))) (quasiquote (lambda (unquote args) (apply (unquote (cadr expr)) this (unquote args)))))) +(define (%class-lambda expr) "(%class-lambda expr)\u000A\u000ADefine lambda that have self is first argument. The expr is in a form:\u000A(constructor (lambda (self ...) . body)) as given by define-class macro." (let ((args (cdadadr expr))) (quasiquote (lambda ((unquote-splicing args)) ((unquote (cadr expr)) this (unquote-splicing args)))))) +(define (%class-method-name expr) "(%class-method-name expr)\u000A\u000AHelper function that allow to use [Symbol.asyncIterator] inside method name." (if (pair? expr) (car expr) (list (quote quote) expr))) +(define-macro (define-class name parent . body) "(define-class name parent . body)\u000A\u000ADefine class - JavaScript function constructor with prototype.\u000A\u000Ausage:\u000A\u000A (define-class Person Object\u000A (constructor (lambda (self name)\u000A (set-obj! self '_name name)))\u000A (hi (lambda (self)\u000A (display (string-append self._name \" say hi\"))\u000A (newline))))\u000A (define jack (new Person \"Jack\"))\u000A (jack.hi)" (let iter ((functions (quote ())) (constructor (quote ())) (lst body)) (if (null? lst) (quasiquote (begin (define (unquote name) (unquote (if (null? constructor) (quasiquote (lambda ())) (%class-lambda constructor)))) (set-obj! (unquote name) (Symbol.for "__class__") #t) (unquote (if (and (not (null? parent)) (not (eq? parent (quote Object)))) (quasiquote (begin (set-obj! (unquote name) (quote prototype) (Object.create (. (unquote parent) (quote prototype)))) (set-obj! (. (unquote name) (quote prototype)) (quote constructor) (unquote name)))))) (unquote-splicing (map (lambda (fn) (quasiquote (set-obj! (. (unquote name) (quote prototype)) (unquote (%class-method-name (car fn))) (unquote (%class-lambda fn))))) functions)))) (let ((item (car lst))) (if (eq? (car item) (quote constructor)) (iter functions item (cdr lst)) (iter (cons item functions) constructor (cdr lst))))))) +(define-syntax class (syntax-rules () ((_) (error "class: parent required")) ((_ parent body ...) (let () (define-class temp parent body ...) temp))) "(class <parent> body ...)\u000A\u000AMacro allow to create anonymous classes. See define-class for details.") +(define (make-tags expr) "(make-tags expression)\u000A\u000AFunction that return list structure of code with better syntax then raw LIPS" (quasiquote (h (unquote (let ((val (car expr))) (if (key? val) (key->string val) val))) (alist->object ((unquote (quote quasiquote)) (unquote (pair-map (lambda (car cdr) (quasiquote ((unquote (key->string car)) (unquote (quote unquote)) (unquote cdr)))) (cadr expr))))) (unquote (if (not (null? (cddr expr))) (if (and (pair? (caddr expr)) (let ((s (caaddr expr))) (and (symbol? s) (eq? s (quote list))))) (quasiquote (list->array (list (unquote-splicing (map make-tags (cdaddr expr)))))) (caddr expr))))))) +(define (%sxml h expr) "(%sxml h expr)\u000A\u000AHelper function that render expression using create element function." (let* ((have-attrs (and (not (null? (cdr expr))) (pair? (cadr expr)) (eq? (caadr expr) (quote @)))) (attrs (if have-attrs (cdadr expr) ())) (rest (if have-attrs (cddr expr) (cdr expr)))) (quasiquote ((unquote h) (unquote (let* ((symbol (car expr)) (name (symbol->string symbol))) (if (char-lower-case? (car (string->list name))) name symbol))) (alist->object ((unquote (quote quasiquote)) (unquote (map (lambda (pair) (cons (symbol->string (car pair)) (list (quote unquote) (cadr pair)))) attrs)))) (unquote-splicing (if (null? rest) () (let ((first (car rest))) (if (pair? first) (map (lambda (expr) (%sxml h expr)) rest) (list first))))))))) +(define-macro (pragma->sxml pragma) (quasiquote (define-macro (sxml expr) "(sxml expr)\u000A\u000AMacro for JSX like syntax but with SXML.\u000Ae.g. usage:\u000A\u000A(sxml (div (@ (data-foo \"hello\")\u000A (id \"foo\"))\u000A (span \"hello\")\u000A (span \"world\")))" (%sxml (quote (unquote pragma)) expr)))) +(pragma->sxml h) +(define-macro (with-tags expr) "(with-tags expression)\u000A\u000AMacro that evalute LIPS shorter code for S-Expression equivalent of JSX.\u000Ae.g.:\u000A\u000A(with-tags (:div (:class \"item\" :id \"item-1\")\u000A (list (:span () \"Random Item\")\u000A (:a (:onclick (lambda (e) (alert \"close\")))\u000A \"close\"))))\u000A\u000AAbove expression can be passed to function that renders JSX (like render in React, Preact)\u000ATo get the string from the macro you can use vhtml library from npm." (make-tags expr)) +(define (get-script url) "(get-script url)\u000A\u000ALoad JavaScript file in browser by adding script tag to head of the current document." (if (not (bound? (quote document))) (throw (new Error "get-script: document not defined")) (let ((script (document.createElement "script"))) (new Promise (lambda (resolve reject) (set-obj! script (quote src) url) (set-obj! script (quote onload) (lambda () (resolve))) (set-obj! script (quote onerror) (lambda () (reject "get-script: Failed to load"))) (if document.head (document.head.appendChild script))))))) +(define (gensym? value) "(gensym? value)\u000A\u000AFunction return #t if value is symbol and it's gensym. It returns #f otherwise." (and (symbol? value) (--> value (is_gensym)))) +(define (degree->radians x) "(degree->radians x)\u000A\u000AConvert degree to radians." (* x (/ Math.PI 180))) +(define (radians->degree x) "(radians->degree x)\u000A\u000AConvert radians to degree." (* x (/ 180 Math.PI))) +(define-syntax while (syntax-rules () ((_ predicate body ...) (do () ((not predicate)) body ...))) "(while cond . body)\u000A\u000AMacro that create a loop, it exectue body until cond expression is false.") +(define-syntax ++ (syntax-rules () ((++ x) (let ((tmp (+ x 1))) (set! x tmp) tmp))) "(++ variable)\u000A\u000AMacro that work only on variables and increment the value by one.") +(define-syntax -- (syntax-rules () ((-- x) (let ((tmp (- x 1))) (set! x tmp) tmp))) "(-- variable)\u000A\u000AMacro that decrement the value it work only on symbols") +(define (pretty-format pair) "(pretty-format pair)\u000A\u000AFunction return pretty printed string from pair expression." (typecheck "pretty-pair" pair "pair") (--> (new lips.Formatter (repr pair #t)) (break) (format))) +(define (reset) "(reset)\u000A\u000AFunction reset environment and remove all user defined variables." (let-env **interaction-environment** (let ((defaults **interaction-environment-defaults**) (env **interaction-environment**)) (--> env (list) (forEach (lambda (name) (if (not (--> defaults (includes name))) (--> env (unset name))))))))) +(define (make-list n . rest) (if (or (not (integer? n)) (<= n 0)) (throw (new Error "make-list: first argument need to be integer larger then 0")) (let ((fill (if (null? rest) undefined (car rest)))) (array->list (--> (new Array n) (fill fill)))))) +(define (range n) "(range n)\u000A\u000AFunction return list of n numbers from 0 to n - 1" (typecheck "range" n "number") (array->list (--> (new Array n) (fill 0) (map (lambda (_ i) i))))) +(define-macro (do-iterator spec cond . body) "(do-iterator (var expr) (test) body ...)\u000A\u000AMacro iterate over iterators (e.g. create with JavaScript generator function)\u000Ait works with normal and async iterators. You can loop over infinite iterators\u000Aand break the loop if you want, using expression like in do macro, long sync iterators\u000Awill block main thread (you can't print 1000 numbers from inf iterators,\u000Abecause it will freeze the browser), but if you use async iterators you can process\u000Athe values as they are generated." (let ((gen (gensym "name")) (name (car spec)) (async (gensym "async")) (sync (gensym "sync")) (iterator (gensym "iterator")) (test (if (null? cond) #f (car cond))) (next (gensym "next")) (stop (gensym "stop")) (item (gensym "item"))) (quasiquote (let* (((unquote gen) (unquote (cadr spec))) ((unquote sync) (. (unquote gen) Symbol.iterator)) ((unquote async) (. (unquote gen) Symbol.asyncIterator)) ((unquote iterator)) ((unquote next) (lambda () ((. (unquote iterator) "next"))))) (if (or (procedure? (unquote sync)) (procedure? (unquote async))) (begin (set! (unquote iterator) (if (procedure? (unquote sync)) ((unquote sync)) ((unquote async)))) (let* (((unquote item) ((unquote next))) ((unquote stop) #f) ((unquote name) (. (unquote item) "value"))) (while (not (or (eq? (. (unquote item) "done") #t) (unquote stop))) (if (unquote test) (set! (unquote stop) #t) (begin (unquote-splicing body))) (set! (unquote item) ((unquote next))) (set! (unquote name) (. (unquote item) "value")))))))))) +(set-repr! Set (lambda () "#<Set>")) +(set-repr! Map (lambda () "#<Met>")) +(define (native-symbol? x) "(native-symbol? object)\u000A\u000AFunction check if value is JavaScript symbol." (and (string=? (type x) "symbol") (not (symbol? x)))) +(set-special! "’" (quote warn-quote)) +(define-macro (warn-quote) "(warn-quote)\u000A\u000ASimple macro that throw error, when you try to use ’ symbol as quote in code" (throw (new Error (string-append "You're using invalid quote character run: " "(set-special! \"’\" 'quote)" " to allow running this type of quote")))) +(define-macro (quote-promise expr) "(quote-promise expr)\u000A'>expr\u000A\u000AMacro used to escape promise the whole expression, will be wrapped\u000Awith JavaScript class that behave like Promise but will not\u000Aauto resolve like normal promise." (quasiquote (let ((env)) (set! env (current-environment)) (env.set (Symbol.for "__promise__") #t) (unquote expr)))) +(define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value)) +(define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body)\u000A\u000AMacro add mapping for variables var from specified env,\u000AMacro work similar to let-env but lexical scope is working with it." (let ((env-name (gensym (quote env)))) (quasiquote (let (((unquote env-name) (unquote env))) (let (unquote (map (lambda (pair) (quasiquote ((unquote (car pair)) (--> (unquote env-name) (get (quote (unquote (cadr pair)))))))) spec)) (unquote-splicing body)))))) +(define-macro (let-std spec . body) "(let-std ((name var)) . body)\u000A\u000AMacro that create aliases for variables in global environment.\u000AThis is needed so user don't change constants like stdin or stdout\u000Athat use taken from lexical scope. The function still can use those\u000Afrom interaction-environment." (quasiquote (let-env-values lips.env.__parent__ (unquote spec) (unquote-splicing body)))) +(define (apropos name) "(apropos name)\u000A\u000ASearch environment and display names that match the given name.\u000Aname can be regex, string or symbol." (typecheck "apropos" name (quote ("string" "regex" "symbol"))) (let ((regex (lambda (string) (new RegExp (escape-regex string))))) (filter (cond ((string? name) (regex name)) ((symbol? name) (regex (symbol->string name))) (else name)) (env)))) +(set-special! "#," (quote sharp-comma)) +(define **reader-ctor-list** (quote ())) +(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**))))) +(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...)))))))))) +(define (promisify fn) "(promisify fn)\u000A\u000ASimple function for adding promises to NodeJS callback based function.\u000AFunction tested only with fs module." (lambda args (new Promise (lambda (resolve reject) (apply fn (append args (list (lambda (err data) (if (null? err) (resolve data) (reject err)))))))))) +(define-macro (list* . args) "(list* arg1 ...)\u000A\u000AParallel version of list." (let ((result (gensym "result"))) (quasiquote (let (((unquote result) (vector))) (unquote-splicing (map (lambda (arg) (quasiquote (--> (unquote result) (push (quote-promise (unquote arg)))))) args)) (map await (vector->list (unquote result))))))) +(define-macro (%not-implemented name) "(not-implemented name)\u000A\u000AReturns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ")\u000A\u000AThis function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented")))))))) +(define-macro (%make-env name . names) "(%make-env name f1 f2 ...)\u000A\u000ACreate new Environment with given name and defined symbols in it from global env.\u000AIf given function name f1 f2 ... don't exists, it will define function that\u000Athrow exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name)))) +(define Y (lambda (h) "(Y f)\u000A\u000A _ __ __ _ _ _ _ __ __ _ _ _\u000A / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\\u000A+ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + +\u000A| \\ / | \\ \\ | | |__ | | \\ / | |__ | | |\u000A| | | | / \\ | | __| | | | | | __| | | |\u000A| | | | / /\\ \\ | | | | | | | | | | | |\u000A+ |_| + /_/ \\_\\ + |_| + + |_| |_| + + +\u000A \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args))))))) +(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs)))) +(define (environment? obj) "(environment? obj)\u000A\u000AFunction check if object is LIPS environment." (instanceof lips.Environment obj)) +(define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path)\u000A\u000ARead file from url or file system. If binary is false it will return\u000Astring that contain all the content. For HTTP requests, If binary\u000Ais false it will: when in browser return ArrayBuffer and in Node\u000Ait will return Buffer object. When reading from file system\u000Ain both cases it will return Buffer objects.\u000A\u000AThe code that use those function, in binary mode, need to check\u000Aif the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) +(define %read-binary-file (curry %read-file #t)) +(define %read-text-file (curry %read-file #f)) +(define (response->content binary res) "(response->text binary res)\u000A\u000AFunction read all text from Node.js HTTP response object. If binary argument is\u000Atrue it will return Buffer object that can be converted to u8vector.\u000A\u000A***Warrning:*** it may overflow the stack (part of Node) when converting\u000Awhole buffer to u8vector." (let ((result (vector))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" (lambda (chunk) (result.push (Buffer.from chunk "binary")))) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join ""))))))))) +(define response->buffer (curry response->content #t)) +(define response->text (curry response->content #f)) +(define http-get (if (eq? self window) (lambda (url binary) "(http-get url)\u000A\u000ANode.js Function that send HTTP Request and return string or\u000Abinary Buffer object." (throw (new Error "http-get: function is Node.js only."))) (let* ((http (. (require "http") (quote get))) (https (. (require "https") (quote get)))) (lambda (url binary) "(http-get url)\u000A\u000ANode.js Function that send HTTP Request and return string or\u000Abinary Buffer object." (let ((request (if (null? (url.match #/^https/)) http https))) (new Promise (lambda (resolve reject) (--> (request url (lambda (res) (if (= res.statusCode 200) (resolve (response->content binary res)) (let ((code res.statusCode)) (res.resume) (reject (string-append "Request return " (number->string code))))))) (on "error" reject))))))))) +(define (buffer->u8vector bin) "(buffer->u8vector bin)\u000A\u000ACross platform function that can be used in both Node and Browser.\u000AIt can be used together with %read-file or %read-binary-file and convert\u000Athe result ArrayBuffer or Buffer to u8vector." (if (instanceof ArrayBuffer bin) (new Uint8Array bin) (Uint8Array.from bin))) +(define string-append concat) +(define = ==) +(define remainder %) +(define -inf.0 Number.NEGATIVE_INFINITY) +(define +inf.0 Number.POSITIVE_INFINITY) +(define procedure? function?) +(define expt **) +(define list->vector list->array) +(define vector->list array->list) +(define-macro (define-symbol-macro type spec . rest) "(define-symbol-macro type (name . args) . body)\u000A\u000AMacro that creates special symbol macro for evaluator similar to build in , or `.\u000AIt's like alias for real macro. Similar to CL reader macros but it receive already\u000Aparsed code like normal macros. Type can be SPLICE or LITERAL symbols.\u000AALL default symbol macros are literal." (let* ((name (car spec)) (symbol (cadr spec)) (args (cddr spec))) (quasiquote (begin (set-special! (unquote symbol) (quote (unquote name)) (unquote (string->symbol (concat "lips.specials." (symbol->string type))))) (define-macro ((unquote name) (unquote-splicing args)) (unquote-splicing rest)))))) +(set-special! "#" (quote vector-literal) lips.specials.SPLICE) +(define-macro (vector-literal . args) (if (not (or (pair? args) (eq? args ()))) (throw (new Error (concat "Parse Error: vector require pair got " (type args) " in " (repr args)))) (let ((v (list->array args))) (Object.freeze v) v))) +(define-syntax vector (syntax-rules () ((_ arg ...) (list->array (list arg ...)))) "(vector 1 2 3 (+ 3 1))\u000A#(1 2 3 4)\u000A\u000AMacro for defining vectors (JavaScript arrays). Vectors literals are\u000Aautomatically quoted. So you can use expressions inside them. Only other\u000Aliterals, like other vectors or object.") +(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")")))) +(define (eqv? a b) "(eqv? a b)\u000A\u000AFunction compare the values. It return true if they are the same, they\u000Aneed to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (cond ((a.isNaN) (b.isNaN)) ((and (zero? a) (zero? b)) (eq? a._minus b._minus)) ((and (complex? a) (complex? b)) (let ((re.a (real-part a)) (re.b (real-part b)) (im.a (imag-part a)) (im.b (imag-part b))) (and (if (and (zero? re.a) (zero? re.b)) (eq? (. re.a (quote _minus)) (. re.b (quote _minus))) #t) (if (and (zero? im.a) (zero? im.b)) (eq? (. im.a (quote _minus)) (. im.b (quote _minus))) #t) (or (= re.a re.b) (and (--> re.a (isNaN)) (--> re.b (isNaN)))) (or (= im.a im.b) (and (--> im.a (isNaN)) (--> im.b (isNaN))))))) (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f)) +(define (equal? a b) "(equal? a b)\u000A\u000AFunction check if values are equal if both are pair or array\u000Ait compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b)))) +(define make-promise (lambda (proc) "(make-promise fn)\u000A\u000AFunction create promise from a function." (typecheck "make-promise" proc "function") (let ((result-ready? #f) (result #f)) (let ((promise (lambda () (if result-ready? result (let ((x (proc))) (if result-ready? result (begin (set! result-ready? #t) (set! result x) result))))))) (set-obj! promise (Symbol.for "promise") #t) (set! promise.toString (lambda () (string-append "#<promise - " (if result-ready? (string-append "forced with " (type result)) "not forced") ">"))) promise)))) +(define-macro (delay expression) "(delay expression)\u000A\u000AMacro will create a promise from expression that can be forced with (force)." (quasiquote (make-promise (lambda () (unquote expression))))) +(define (force promise) "(force promise)\u000A\u000AFunction force the promise and evaluate delayed expression." (promise)) +(define (promise? obj) "(promise? obj)\u000A\u000AFunction check if value is a promise created with delay or make-promise." (string=? (type obj) "promise")) +(define (positive? x) "(positive? x)\u000A\u000AFunction check if number is larger then 0" (typecheck "positive?" x "number") (> x 0)) +(define (negative? x) "(negative? x)\u000A\u000AFunction check if number is smaller then 0" (typecheck "negative?" x "number") (< x 0)) +(define (zero? x) "(zero? x)\u000A\u000AFunction check if number is equal to 0" (typecheck "zero?" x "number") (= x 0)) +(define (quotient a b) "(quotient a b)\u000A\u000AReturn quotient from divition as integer." (typecheck "quotient" a "number") (typecheck "quotient" b "number") (if (zero? b 0) (throw (new Error "quotient: divition by zero")) (let ((quotient (/ a b))) (if (integer? quotient) quotient (if (> quotient 0) (floor quotient) (ceiling quotient)))))) +(define (number->string x . rest) "(number->string x [radix])\u000A\u000AFunction convert number to string with optional radix (number base)." (typecheck "number->string" x "number" 1) (let ((radix (if (null? rest) 10 (car rest)))) (typecheck "number->string" radix "number" 2) (--> x (toString (--> radix (valueOf)))))) +(define (boolean? x) "(boolean? x)\u000A\u000AFunction return true if value is boolean." (string=? (type x) "boolean")) +(define (vector-ref vector i) "(vector-ref vector i)\u000A\u000AReturn i element from vector." (typecheck "number->string" vector "array" 1) (typecheck "number->string" i "number" 2) (. vector i)) +(define (vector-set! vector i obj) "(vector-set! vector i obj)\u000A\u000ASet obj as value in vector at position 1." (typecheck "vector-set!" vector "array" 1) (typecheck "vector-set!" i "number" 2) (set-obj! vector i obj)) +(define (%number-type type x) (typecheck "%number-type" type (vector "string" "pair")) (typecheck "%number-type" x "number") (let* ((t x.__type__) (typeof (lambda (type) (string=? t type)))) (and (number? x) (if (pair? type) (some typeof type) (typeof type))))) +(define (real? x) "(real? x)\u000A\u000AFunction check if argument x is real." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (%number-type "complex" x) (let ((i (imag-part x))) (and (zero? i) (exact? i)))) (%number-type (quote ("float" "bigint" "rational")) x)))) +(define (integer? x) "(integer? x)\u000A\u000AFunction check if argument x is integer." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "bigint" x) (and (%number-type "float" x) (= (modulo x 2) 1))))) +(define (complex? x) "(complex? x)\u000A\u000AFunction check if argument x is complex." (and (number? x) (or (eq? x NaN) (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (%number-type (quote ("complex" "float" "bigint" "rational")) x)))) +(define (rational? x) "(rational? x)\u000A\u000AFunction check if value is rational." (and (number? x) (not (eq? x NaN)) (not (eq? x Number.NEGATIVE_INFINITY)) (not (eq? x Number.POSITIVE_INFINITY)) (or (%number-type "rational" x) (integer? x)))) +(define (typecheck-args _type name _list) "(typecheck-args args type)\u000A\u000AFunction check if all items in array are of same type." (let iter ((n 1) (_list _list)) (if (pair? _list) (begin (typecheck name (car _list) _type n) (iter (+ n 1) (cdr _list)))))) +(define numbers? (curry typecheck-args "number")) +(define (max . args) "(max n1 n2 ...)\u000A\u000AReturn maximum of it's arguments." (numbers? "max" args) (apply (.. Math.max) args)) +(define (min . args) "(min n1 n2 ...)\u000A\u000AReturn minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) args)) +(define (make-rectangular re im) "(make-rectangular im re)\u000A\u000ACreate complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t))))) +(define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__))))) +(define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n))) +(define (exact->inexact n) "(exact->inexact n)\u000A\u000AConvert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (exact->inexact (. n (quote __im__))) :re (exact->inexact (. n (quote __re__))))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n))) +(define (inexact->exact n) "(inexact->exact number)\u000A\u000AFuncion convert real number to exact ratioanl number." (typecheck "inexact->exact" n "number") (if (or (real? n) (%number-type "complex" n)) (--> n (toRational)) n)) +(define _maths (list "exp" "log" "sin" "cos" "tan" "asin" "acos" "atan" "atan")) +(define _this_env (current-environment)) +(let iter ((fns _maths)) (if (not (null? fns)) (let* ((name (car fns)) (LNumber (.. lips.LNumber)) (op (. Math name)) (fn (lambda (n) (LNumber (op n))))) (--> _this_env (set name fn)) (set-obj! fn (quote __doc__) (concat "(" name " n)\u000A\u000AFunction calculate " name " math operation (it call JavaScript Math)." name " function.")) (iter (cdr fns))))) +(define (modulo a b) "(modulo a b)\u000A\u000AFunction return modulo operation on it's argumennts." (typecheck "modulo" a "number" 1) (typecheck "modulo" b "number" 2) (- a (* b (floor (/ a b))))) +(define (remainder__ a b) "(modulo a b)\u000A\u000AFunction return reminder from division operation." (typecheck "remainder" a "number" 1) (typecheck "remainder" b "number" 2) (- a (* b (truncate (/ a b))))) +(define (list-tail l k) "(list-tail list k)\u000A\u000AReturns the sublist of list obtained by omitting the first k elements." (typecheck "list-tail" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-tail: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) l))) +(define (list-ref l k) "(list-ref list n)\u000A\u000AReturns n element of a list." (typecheck "list-ref" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l))))) +(define (not x) "(not x)\u000A\u000AFunction return true if value is false and false otherwise." (if x #f #t)) +(define (rationalize number tolerance) "(rationalize number tolerance)\u000A\u000AFunction returns simplest rational number differing from number by no more\u000Athan the tolerance." (typecheck "rationalize" number "number" 1) (typecheck "rationalize" tolerance "number" 2) (lips.rationalize number tolerance)) +(define (%mem/search access op obj list) "(%member obj list function)\u000A\u000AHelper method to get first list where car equal to obj\u000Ausing provied functions as comparator." (if (null? list) #f (if (op (access list) obj) list (%mem/search access op obj (cdr list))))) +(define (memq obj list) "(memq obj list)\u000A\u000AFunction return first object in the list that match using eq? function." (typecheck "memq" list (quote ("nil" "pair"))) (%mem/search car eq? obj list)) +(define (memv obj list) "(memv obj list)\u000A\u000AFunction return first object in the list that match using eqv? function." (typecheck "memv" list (quote ("nil" "pair"))) (%mem/search car eqv? obj list)) +(define (member obj list) "(member obj list)\u000A\u000AFunction return first object in the list that match using equal? function." (typecheck "member" list (quote ("nil" "pair"))) (%mem/search car equal? obj list)) +(define (%assoc/acessor name) "(%assoc/acessor name)\u000A\u000AFunction return carr with typecheck using give name." (lambda (x) (typecheck name x "pair") (caar x))) +(define (%assoc/search op obj alist) "(%assoc/search op obj alist)\u000A\u000AGeneric function that used in assoc functions with defined comparator\u000Afunction." (typecheck "assoc" alist (vector "nil" "pair")) (let ((ret (%mem/search (%assoc/acessor "assoc") op obj alist))) (if ret (car ret) ret))) +(define assoc (%doc "(assoc obj alist)\u000A\u000AFunction return pair from alist that match given key using equal? check." (curry %assoc/search equal?))) +(define assq (%doc "(assq obj alist)\u000A\u000AFunction return pair from alist that match given key using eq? check." (curry %assoc/search eq?))) +(define assv (%doc "(assv obj alist)\u000A\u000AFunction return pair from alist that match given key using eqv? check." (curry %assoc/search eqv?))) +(define (make-string k . rest) "(make-string k [char])\u000A\u000AFunction return new string with k elements, if char is provied\u000Ait's filled with that character." (let ((char (if (null? rest) #\space (car rest)))) (typecheck "make-string" k "number" 1) (typecheck "make-string" char "character" 2) (let iter ((result (quote ())) (k k)) (if (<= k 0) (list->string result) (iter (cons char result) (- k 1)))))) +(define (string . args) "(string chr1 chr2 ...)\u000A\u000AFunction create new string from it's arguments. Each argument\u000ANeed to be a character object." (for-each (lambda (x) (typecheck "string" x "character")) args) (list->string args)) +(define (string-copy string) "(string-copy string)\u000A\u000AReturns a copy of the given string." (typecheck "string-copy" string "string") (--> string (clone))) +(define (string-fill! string char) "(string-fill! symbol char)\u000A\u000AFunction destructively fill the string with given character." (typecheck "string-fill!" string "string" 1) (typecheck "string-fill!" char "character" 2) (--> string (fill char))) +(define (identity n) "(identity n)\u000A\u000ANo op function. it just returns its argument." n) +(define (string-copy x) "(string-copy x)\u000A\u000ACreate new string based of given argument." (typecheck "string-copy" x "string") (lips.LString x)) +(define (list->string _list) "(list->string _list)\u000A\u000AFunction return string from list of characters." (let ((array (list->array (map (lambda (x) (typecheck "list->string" x "character") (x.valueOf)) _list)))) (--> array (join "")))) +(define (string->list string) "(string->list string)\u000A\u000AFunction return list of characters created from string." (typecheck "string->list" string "string") (array->list (--> string (split "") (map (lambda (x) (lips.LCharacter x)))))) +(define-macro (string-set! object index char) "(string-set! object index char)\u000A\u000AMacro that replace character in string in given index, it create new JavaScript\u000Astring and replace old value. Object need to be symbol that point to variable\u000Athat hold the string." (typecheck "string-set!" object "symbol") (let ((chars (gensym "chars"))) (quasiquote (begin (typecheck "string-set!" (unquote object) "string") (typecheck "string-set!" (unquote index) "number") (typecheck "string-set!" (unquote char) "character") (let (((unquote chars) (list->vector (string->list (unquote object))))) (set-obj! (unquote chars) (unquote index) (unquote char)) (set! (unquote object) (list->string (vector->list (unquote chars))))))))) +(define (string-length string) "(string-length string)\u000A\u000AFunction return length of the string." (typecheck "string-ref" string "string") (. string (quote length))) +(define (string-ref string k) "(string-ref string k)\u000A\u000AFunction return character inside string at given zero-based index." (typecheck "string-ref" string "string" 1) (typecheck "string-ref" k "number" 2) (lips.LCharacter (--> string (get k)))) +(define (%string-cmp name string1 string2) "(%string-cmp name a b)\u000A\u000AFunction compare two strings and return 0 if they are equal,\u000A-1 second is smaller and 1 if is larget. The function compare\u000Athe codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (cmp string2))) +(define (string=? string1 string2) "(string=? string1 string2)\u000A\u000AFunction check if two string s are equal." (= (%string-cmp "string=?" string1 string2) 0)) +(define (string<? string1 string2) "(string<? string1 string2)\u000A\u000AFunction return true if second string is smaller then the first one." (= (%string-cmp "string<?" string1 string2) -1)) +(define (string>? string1 string2) "(string<? string1 string2)\u000A\u000AFunction return true if second string is larger then the first one." (= (%string-cmp "string>?" string1 string2) 1)) +(define (string<=? string1 string2) "(string<? string1 string2)\u000A\u000AFunction return true if second string is not larger then the first one." (< (%string-cmp "string<=?" string1 string2) 1)) +(define (string>=? string1 string2) "(string<? string1 string2)\u000A\u000AFunction return true if second character is not smaller then the first one." (> (%string-cmp "string>=?" string1 string2) -1)) +(define (%string-ci-cmp name string1 string2) "(%string-ci-cmp name a b)\u000A\u000AFunction compare two strings ingoring case and return 0 if they are equal,\u000A-1 second is smaller and 1 if is larget. The function compare\u000Athe codepoints of the character." (typecheck name string1 "string" 1) (typecheck name string2 "string" 2) (--> string1 (lower) (cmp (--> string2 (lower))))) +(define (string-ci=? string1 string2) "(string-ci=? string1 string2)\u000A\u000AFunction check if two string s are equal." (= (%string-ci-cmp "string-ci=?" string1 string2) 0)) +(define (string-ci<? string1 string2) "(string-ci<? string1 string2)\u000A\u000AFunction return true if second string is smaller then the first one." (= (%string-ci-cmp "string-ci<?" string1 string2) -1)) +(define (string-ci>? string1 string2) "(string-ci<? string1 string2)\u000A\u000AFunction return true if second string is larger then the first one." (= (%string-ci-cmp "string-ci>?" string1 string2) 1)) +(define (string-ci<=? string1 string2) "(string-ci<? string1 string2)\u000A\u000AFunction return true if second string is not larger then the first one." (< (%string-ci-cmp "string-ci<=?" string1 string2) 1)) +(define (string-ci>=? string1 string2) "(string-ci>=? string1 string2)\u000A\u000AFunction return true if second character is not smaller then the first one." (> (%string-ci-cmp "string-ci>=?" string1 string2) -1)) +(define char? (%doc "(char? obj)\u000A\u000AFunction check if object is character." (curry instanceof lips.LCharacter))) +(define (char->integer chr) "(char->integer chr)\u000A\u000AFunction return codepoint of Unicode character." (typecheck "char->integer" chr "character") (--> chr.__char__ (codePointAt 0))) +(define (integer->char n) "(integer->char chr)\u000A\u000AFunction convert number argument to chararacter." (typecheck "integer->char" n "number") (if (integer? n) (string-ref (String.fromCodePoint n) 0) (throw "argument to integer->char need to be integer."))) +(define-macro (%define-chr-re spec str re) "(%define-chr-re (name chr) sring re)\u000A\u000AMacro define procedure that test character agains regular expression." (quasiquote (define (unquote spec) (unquote str) (typecheck (unquote (symbol->string (car spec))) (unquote (cadr spec)) "character") (not (null? (--> chr (toString) (match (unquote re)))))))) +(%define-chr-re (char-whitespace? chr) "(char-whitespace? chr)\u000A\u000AFunction return true if character is whitespace." (let-env (interaction-environment) (--> **internal-env** (get (quote space-unicode-regex))))) +(%define-chr-re (char-numeric? chr) "(char-numeric? chr)\u000A\u000AFunction return true if character is number." (let-env (interaction-environment) (--> **internal-env** (get (quote numeral-unicode-regex))))) +(%define-chr-re (char-alphabetic? chr) "(char-alphabetic? chr)\u000A\u000AFunction return true if character is leter of the ASCII alphabet." (let-env (interaction-environment) (--> **internal-env** (get (quote letter-unicode-regex))))) +(define (%char-cmp name chr1 chr2) "(%char-cmp name a b)\u000A\u000AFunction compare two characters and return 0 if they are equal,\u000A-1 second is smaller and 1 if is larget. The function compare\u000Athe codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (let ((a (char->integer chr1)) (b (char->integer chr2))) (cond ((= a b) 0) ((< a b) -1) (else 1)))) +(define (char=? chr1 chr2) "(char=? chr1 chr2)\u000A\u000AFunction check if two characters are equal." (= (%char-cmp "char=?" chr1 chr2) 0)) +(define (char<? chr1 chr2) "(char<? chr1 chr2)\u000A\u000AFunction return true if second character is smaller then the first one." (= (%char-cmp "char<?" chr1 chr2) -1)) +(define (char>? chr1 chr2) "(char<? chr1 chr2)\u000A\u000AFunction return true if second character is larger then the first one." (= (%char-cmp "char>?" chr1 chr2) 1)) +(define (char<=? chr1 chr2) "(char<? chr1 chr2)\u000A\u000AFunction return true if second character is not larger then the first one." (< (%char-cmp "char<=?" chr1 chr2) 1)) +(define (char>=? chr1 chr2) "(char<? chr1 chr2)\u000A\u000AFunction return true if second character is not smaller then the first one." (> (%char-cmp "char>=?" chr1 chr2) -1)) +(define (%char-ci-cmp name chr1 chr2) "(%char-cmp name a b)\u000A\u000AFunction compare two characters and return 0 if they are equal,\u000A-1 second is smaller and 1 if is larget. The function compare\u000Athe codepoints of the character." (typecheck name chr1 "character" 1) (typecheck name chr2 "character" 2) (%char-cmp name (char-downcase chr1) (char-downcase chr2))) +(define (char-ci=? chr1 chr2) "(char-ci=? chr1 chr2)\u000A\u000AFunction check if two characters are equal." (= (%char-ci-cmp "char-ci=?" chr1 chr2) 0)) +(define (char-ci<? chr1 chr2) "(char-ci<? chr1 chr2)\u000A\u000AFunction return true if second character is smaller then the first one." (= (%char-ci-cmp "char-ci<?" chr1 chr2) -1)) +(define (char-ci>? chr1 chr2) "(char-ci<? chr1 chr2)\u000A\u000AFunction return true if second character is larger then the first one." (= (%char-ci-cmp "char-ci>?" chr1 chr2) 1)) +(define (char-ci<=? chr1 chr2) "(char-ci<? chr1 chr2)\u000A\u000AFunction return true if second character is not larger then the first one." (< (%char-ci-cmp "char-ci<=?" chr1 chr2) 1)) +(define (char-ci>=? chr1 chr2) "(char-ci<? chr1 chr2)\u000A\u000AFunction return true if second character is not smaller then the first one." (> (%char-ci-cmp "char-ci>=?" chr1 chr2) -1)) +(define (char-upcase char) "(char-upcase char)\u000A\u000ACreate uppercase version of the character." (typecheck "char-upcase" char "character") (char.toUpperCase)) +(define (char-downcase char) "(char-downcase chr)\u000A\u000ACreate lowercase version of the character." (typecheck "char-upcase" char "character") (char.toLowerCase)) +(define (char-upper-case? char) "(char-upper-case? char)\u000A\u000AFunction check if character is upper case." (typecheck "char-upper-case?" char "character") (and (char-alphabetic? char) (char=? (char-upcase char) char))) +(define (char-lower-case? char) "(char-upper-case? char)\u000A\u000AFunction check if character is lower case." (typecheck "char-lower-case?" char "character") (and (char-alphabetic? char) (char=? (char-downcase char) char))) +(define (newline . rest) "(newline [port])\u000A\u000AWrite newline character to standard output or given port" (let ((port (if (null? rest) (current-output-port) (car rest)))) (display "\u000A" port))) +(define (write obj . rest) "(write obj [port])\u000A\u000AWrite object to standard output or give port. For strings it will include\u000Awrap in quotes." (let ((port (if (null? rest) (current-output-port) (car rest)))) (display (repr obj #t) port))) +(define (write-char char . rest) "(write-char char [port])\u000A\u000AWrite single character to given port using write function." (typecheck "write-char" char "character") (if (not (null? rest)) (typecheck "write-char" (car rest) "output-port")) (apply display (cons (char.valueOf) rest))) +(define fold-right reduce) +(define fold-left fold) +(define (make-vector n . rest) "(make-vector n [fill])\u000A\u000ACreate new vector with n empty elements. If fill is specified it will set\u000Aall elements of the vector to that value." (let ((result (new Array n))) (if (not (null? rest)) (--> result (fill (car rest))) result))) +(define (vector? n) "(vector? n)\u000A\u000AFunction return true of value is vector and false if not." (string=? (type n) "array")) +(define (vector-ref vec n) "(vector-ref vec n)\u000A\u000AFunction return nth element of the vector vec." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (. vec n)) +(define (vector-set! vec n value) "(vector-set! vec n value)\u000A\u000AFunction set nth item of the vector to value." (typecheck "vector-ref" vec "array" 1) (typecheck "vector-ref" n "number" 2) (set-obj! vec n value)) +(define (vector-fill! vec value) "(vector-fill! vec value)\u000A\u000ASet every element of the vector to given value." (typecheck "vector-ref" vec "array") (let recur ((n (- (length vec) 1))) (if (>= n 0) (begin (set-obj! vec n value) (recur (- n 1)))))) +(define (vector-length vec) "(vector-length vec)\u000A\u000AFunction return length of the vector. If argument is not vector it throw exception." (typecheck "vector-length" vec "array") (length vec)) +(define-syntax case (syntax-rules (else =>) ((case (key ...) clauses ...) (let ((atom-key (key ...))) (case atom-key clauses ...))) ((case key (else => result)) (result key)) ((case key (else result1 result2 ...)) (begin result1 result2 ...)) ((case key ((atoms ...) result1 result2 ...)) (if (memv key (quote (atoms ...))) (begin result1 result2 ...))) ((case key ((atoms ...) => result)) (if (memv key (quote (atoms ...))) (result key))) ((case key ((atoms ...) => result) clause clauses ...) (if (memv key (quote (atoms ...))) (result key) (case key clause clauses ...))) ((case key ((atoms ...) result1 result2 ...) clause clauses ...) (if (memv key (quote (atoms ...))) (begin result1 result2 ...) (case key clause clauses ...)))) "(case value\u000A ((<items>) result1)\u000A ((<items>) result2)\u000A [else result3])\u000A\u000AMacro for switch case statement. It test if value is any of the item. If\u000Aitem match the value it will return coresponding result expression value.\u000AIf no value match and there is else it will return that result.") +(--> lips.Formatter.defaults.exceptions.specials (push "case")) +(define (numerator n) "(numerator n)\u000A\u000AReturn numberator of rational or same number if n is not rational." (typecheck "numerator" n "number") (if (and (rational? n) (not (integer? n))) n.num n)) +(define (denominator n) "(denominator n)\u000A\u000AReturn denominator of rational or same number if one is not rational." (typecheck "denominator" n "number") (if (and (rational? n) (not (integer? n))) n.denom (if (exact? n) 1 1.0))) +(define (imag-part n) "(imag-part n)\u000A\u000AReturn imaginary part of the complex number n." (typecheck "imag-part" n "number") (if (%number-type "complex" n) n.__im__ 0)) +(define (real-part n) "(real-part n)\u000A\u000AReturn real part of the complex number n." (typecheck "real-part" n "number") (if (%number-type "complex" n) n.__re__ n)) +(define (make-polar r angle) "(make-polar magnitude angle)\u000A\u000ACreate new complex number from polar parameters." (typecheck "make-polar" r "number") (typecheck "make-polar" angle "number") (if (or (complex? r) (complex? angle)) (error "make-polar: argument can't be complex") (let ((re (* r (sin angle))) (im (* r (cos angle)))) (make-rectangular im re)))) +(define (angle x) "(angle x)\u000A\u000AReturns angle of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "angle: number need to be complex") (Math.atan2 x.__im__ x.__re__))) +(define (magnitude x) "(magnitude x)\u000A\u000AReturns magnitude of the complex number in polar coordinate system." (if (not (%number-type "complex" x)) (error "magnitude: number need to be complex") (sqrt (+ (* x.__im__ x.__im__) (* x.__re__ x.__re__))))) +(define random (let ((a 69069) (c 1) (m (expt 2 32)) (seed 19380110)) (lambda new-seed "(random)\u000A(random seed)\u000A\u000AFunction generate new random real number using Knuth algorithm." (if (pair? new-seed) (set! seed (car new-seed)) (set! seed (modulo (+ (* seed a) c) m))) (exact->inexact (/ seed m))))) +(define (eof-object? obj) "(eof-object? arg)\u000A\u000AFunction check if value is eof object, returned from input string\u000Aport when there are no more data to read." (eq? obj eof)) +(define (output-port? obj) "(output-port? arg)\u000A\u000AFunction return true if argument is output port." (instanceof lips.OutputPort obj)) +(define (input-port? obj) "(input-port? arg)\u000A\u000AFunction return true if argument is input port." (instanceof lips.InputPort obj)) +(define (char-ready? . rest) "(char-ready?)\u000A(char-ready? port)\u000A\u000AFunction check it characters is ready in input port. This is usefull mostly\u000Afor interactive ports that return false if it would wait for user input.\u000AIt return false if port is closed." (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "char-ready?" port "input-port") (port.char_ready))) +(define open-input-file (let ((readFile #f)) (lambda (filename) "(open-input-file filename)\u000A\u000AFunction return new Input Port with given filename. In Browser user need to\u000Aprovide global fs variable that is instance of FS interface." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (begin (if (not (procedure? readFile)) (let ((_readFile (promisify fs.readFile))) (set! readFile (lambda (filename) (--> (_readFile filename) (toString)))))) (new lips.InputFilePort (readFile filename) filename))))))) +(define (close-input-port port) "(close-input-port port)\u000A\u000AProcedure close port that was opened with open-input-file. After that\u000Ait no longer accept reading from that port." (typecheck "close-input-port" port "input-port") (port.close)) +(define (close-output-port port) "(close-output-port port)\u000A\u000AProcedure close port that was opened with open-output-file. After that\u000Ait no longer accept write to that port." (typecheck "close-output-port" port "output-port") (port.close)) +(define (call-with-input-file filename proc) "(call-with-input-file filename proc)\u000A\u000AProcedure open file for reading, call user defined procedure with given port\u000Aand then close the port. It return value that was returned by user proc\u000Aand it close the port even if user proc throw exception." (let ((p (open-input-file filename))) (try (proc p) (finally (close-input-port p))))) +(define (call-with-output-file filename proc) "(call-with-output-file filename proc)\u000A\u000AProcedure open file for writing, call user defined procedure with port\u000Aand then close the port. It return value that was returned by user proc and it close the port\u000Aeven if user proc throw exception." (let ((p (open-output-file filename))) (try (proc p) (finally (close-output-port p))))) +(define (with-input-from-file string thunk) "(with-input-from-file string thunk)\u000A\u000AProcedure open file and make it current-input-port then thunk is executed.\u000AAfter thunk is executed current-input-port is restored and file port\u000Ais closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port))))) +(define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port))))) +(define (file-exists? filename) (new Promise (lambda (resolve) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))) +(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))) +(define (scheme-report-environment version) "(scheme-report-environment version)\u000A\u000AFunction return new Environment object for given Scheme Spec version.\u000AOnly argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported")))))) +(define-macro (%make-vector prefix type help) "(%make-vector prefix type help)\u000A\u000AMega helper macro that create list of functions for single byte vector\u000Abased on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...)\u000A\u000ACreate ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v)\u000A\u000Areturn length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a v1 v2 ...)\u000A\u000AAllocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x)\u000A\u000AFunction return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k)\u000A\u000AFunction set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote)))))))) +(%make-vector u8 Uint8Array "usigned 8-bit integer vector") +(%make-vector s8 Int8Array "signed 8-bit integer vector") +(%make-vector u16 Uint16Array "usigned 16-bit integer vector") +(%make-vector s16 Int16Array "signed 16-bit integer vector") +(%make-vector u32 Uint16Array "usigned 32-bit integer vector") +(%make-vector s32 Int16Array "signed 32-bit integer vector") +(%make-vector f32 Float32Array "32-bit IEEE floating point number vector") +(%make-vector f64 Float64Array "64-bit IEEE floating point number vector") +(define (list-match? predicate list) "(list-match? predicate list)\u000A\u000AFunction check if consecutive elements of the list match the predicate function." (typecheck "list-match?" predicate #("function" "macro")) (typecheck "list-match?" list "pair") (or (or (null? list) (null? (cdr list))) (and (predicate (car list) (cadr list)) (list-match? predicate (cdr list))))) +(define (symbol=? . args) "(symbol=? s1 s2 ...)\u000A\u000AFunction check if each value is symbol and it's the same acording to string=? predicate." (list-match? (lambda (a b) (and (symbol? a) (symbol? b) (equal? a b))) args)) +(define (values-ref values n) "(values-ref values n)\u000A\u000AFunction return n value of values object which is result of value function." (typecheck "values-ref" values "values" 1) (typecheck "values-ref" n "number" 1) (--> values (valueOf) n)) +(define-syntax let-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ (((x ...) values) ...) body ...) (apply (lambda (x ... ...) body ...) (vector->list (apply vector-append (map (lambda (x) ((. x "valueOf"))) (list values ...))))))) "(let-values binding body ...)\u000A\u000AThe macro work similar to let but variable is list of values and value\u000Aneed to evaluate to result of calling values.") +(define (vector-append . args) "(vector-append v1 v2 ...)\u000A\u000AFunction return new vector by combining it's arguments that should be vectors." (if (null? args) (vector) (begin (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args))))))) +(define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...)\u000A\u000AThe macro work similar to let* but variable is list of values and value\u000Aneed to evaluate to result of calling values.") +(define (quotient&remainder x y) (values (quotient x y) (remainder x y))) +(define (floor/ x y) (let ((q (quotient x y)) (r (remainder x y))) (if (>= x 0) (if (or (> y 0) (zero? r)) (values q r) (values (- q 1) (+ r y))) (if (and (> y 0) (not (zero? r))) (values (- q 1) (+ r y)) (values q r))))) +(define (floor-quotient x y) (values-ref (floor/ x y) 0)) +(define (floor-remainder x y) (modulo x y)) +(define (truncate/ x y) (quotient&remainder x y)) +(define (truncate-quotient x y) (quotient x y)) +(define (truncate-remainder x y) (remainder x y)) +(define-syntax case-lambda (syntax-rules () ((case-lambda (params body0 ...) ...) (lambda args (let ((len (length args))) (letrec-syntax ((cl (syntax-rules ::: () ((cl) (error "no matching clause")) ((cl ((p :::) . body) . rest) (if (= len (length (quote (p :::)))) (apply (lambda (p :::) . body) args) (cl . rest))) ((cl ((p ::: . tail) . body) . rest) (if (>= len (length (quote (p :::)))) (apply (lambda (p ::: . tail) . body) args) (cl . rest)))))) (cl (params body0 ...) ...)))))) "(case-lambda expr ...)\u000A\u000AMacro create new function with different version of the function depend on\u000Anumber of arguments. Each expression is similar to single lambda.\u000A\u000Ae.g.:\u000A\u000A (define sum\u000A (case-lambda\u000A ((x) x)\u000A ((x y) (+ x y))\u000A ((x y z) (+ x y z))))\u000A\u000A (sum 1)\u000A (sum 1 2)\u000A (sum 1 2 3)\u000A\u000AMore arguments will give error.") +(define (boolean=? . args) "(boolean=? b1 b2 ...)\u000A\u000AFunction check if all arguments are boolean and if they are the same." (if (< (length args) 2) (error "boolean=?: too few arguments") (reduce (lambda (acc item) (and (boolean? item) (eq? acc item))) (car args) (cdr args)))) +(define (port? x) "(port? x)\u000A\u000AFunction return true of argumet is nput or output port port object." (or (output-port? x) (input-port? x))) +(define (square x) "(square z)\u000A\u000AReturns the square of z. This is equivalent to (* z z)." (* x x)) +(define-syntax when (syntax-rules () ((when test result1 result2 ...) (if test (begin result1 result2 ...)))) "(when test body ...)\u000A\u000AMacro execute body when test expression is true.") +(define-syntax unless (syntax-rules () ((unless test result1 result2 ...) (if (not test) (begin result1 result2 ...)))) "(unless test body ...)\u000A\u000AMacro execute body when test expression is false.") +(define inexact exact->inexact) +(define exact inexact->exact) +(define (exact-integer? n) "(exact-integer? n)\u000A\u000AFunction returns #t if z is both exact and an integer; otherwise\u000Areturns #f." (and (integer? n) (exact? n))) +(define (string->vector s) "(string->vector string)\u000A\u000AFunction return vector of characters created from string." (typecheck "string->list" s "string") (--> s (split "") (map (lambda (x) (lips.LCharacter x))))) +(define (vector->string v) "(vector->string vector)\u000A\u000AFunction return new string created from vector of characters." (typecheck "vector->list" v "array") (--> v (map (lambda (char) (char.valueOf))) (join ""))) +(define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...)\u000A\u000AFunction return new vector from applying function fn to each element\u000Aof the vectors, similar to map for lists." (if (or (= (length rest) 0) (not (every vector? rest))) (error "vector-map: function require at least 1 vector") (let ((len (apply min (map vector-length rest))) (result (vector))) (do ((i 0 (+ i 1))) ((= i len) result) (let* ((args (map (lambda (v) (vector-ref v i)) rest)) (value (apply fn args))) (--> result (push value))))))) +(define (string-map fn . rest) "(string-map fn string1 stringr2 ...)\u000A\u000AFunction return new string from applying function fn to each element\u000Aof the strings, similar to map for lists." (if (or (= (length rest) 0) (not (every string? rest))) (error "string-map: function require at least 1 string") (vector->string (apply vector-map fn (map string->vector rest))))) +(define (dynamic-wind before thunk after) "(dynamic-wind before thunk after)\u000A\u000AFunction accept 3 procedures/lambdas and execute thunk with before and always\u000Aafter even if error accur" (before) (let ((result (try (thunk) (catch (e) (error e))))) (after) result)) +(define (with-exception-handler handler thunk) "(with-exception-handler handler thunk)\u000A\u000AProcedure call and return value of thunk function, if exception happen\u000Ait call handler procedure." (try (thunk) (catch (e) (handler e)))) +(define raise throw) +(define-syntax define-values (syntax-rules () ((define-values () expr) (define dummy (call-with-values (lambda () expr) (lambda args #f)))) ((define-values (var) expr) (define var expr)) ((define-values (var0 var1 ... varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cadr var0))) (set! var0 (car var0)) v)))) ((define-values (var0 var1 ... . varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cdr var0))) (set! var0 (car var0)) v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) list)))) "(define-values (a b ...) expr)\u000A\u000AFunction evaluate expression expr and if it evaluates to result of values\u000Athen it will defined each value as variable like with define.") +(define-macro (include . files) "(include file ...)\u000A\u000AMacro that load at least one file content and insert them into one,\u000Abody expression." (if (null? files) (throw (new Error "include: at least one file path required")) (let ((result (vector)) (env (interaction-environment))) (if (eq? self global) (let* ((fs (require "fs")) (readFile (lambda (file) (new Promise (lambda (resolve reject) (fs.readFile file (lambda (err data) (if (null? err) (resolve (--> data (toString))) (reject err))))))))) (for-each (lambda (file) (let* ((expr (lips.parse (readFile file) env))) (set! result (--> result (concat expr))))) files)) (for-each (lambda (file) (let* ((text (--> (fetch file) (text))) (expr (lips.parse text env))) (set! result (--> result (concat expr))))) files)) (if (> result.length 0) (quasiquote (begin (unquote-splicing (vector->list result)))))))) +(define-syntax syntax-error (syntax-rules () ((_ "step" arg ...) (join " " (vector->list (vector (repr arg) ...)))) ((_ message arg ...) (raise (new Error (format "~a ~a" message (_ "step" arg ...))))))) +(define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...)))) +(define (features) (quote (r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower))) +(define *zero-number-chars* #(48 1632 1776 1984 2406 2534 2662 2790 2918 3046 3174 3302 3430 3558 3664 3792 3872 4160 4240 6112 6160 6470 6608 6784 6800 6992 7088 7232 7248 42528 43216 43264 43472 43504 43600 44016 65296 66720 68912 69734 69872 69942 70096 70384 70736 70864 71248 71360 71472 71904 72016 72784 73040 73120 92768 93008 120782 120792 120802 120812 120822 123200 123632 125264 130032)) +(define (digit-value chr) "(digit-value chr)\u000A\u000AReturn digit number if character is numeral (as per char-numeric?)\u000Aor #f otherwise." (typecheck "digit-value" chr "character") (if (char-numeric? chr) (let ((ord (char->integer chr))) (do ((i (vector-length *zero-number-chars*) (- i 1)) (found #f) (result #f)) ((or (zero? i) found) result) (let* ((zero (vector-ref *zero-number-chars* (- i 1))) (diff (- ord zero))) (if (and (>= diff 0) (<= diff 9)) (begin (set! result diff) (set! found #t)))))) #f)) +(define make-bytevector make-u8vector) +(define bytevector u8vector) +(define bytevector? u8vector?) +(define bytevector-length u8vector-length) +(define bytevector-u8-ref u8vector-ref) +(define bytevector-u8-set! u8vector-set!) +(define (bytevector-append v1 . rest) "(bytevector-append v1 ...)\u000A\u000ACreate new bytevector u8vector that is created from joining each argument." (typecheck "bytevector-append" v1 "uint8array" 1) (map (lambda (arg) (typecheck "bytevector-append" arg "uint8array")) rest) (if (null? rest) v1 (new Uint8Array (apply vector-append (Array.from v1) (map Array.from rest))))) +(define (bytevector-copy v . rest) "(bytevector-copy v)\u000A(bytevector-copy v start)\u000A(bytevector-copy v start end)\u000A\u000AFunction and return new vector from start to end. If no start and end is provided\u000Awhole vector is copied and returned." (if (null? rest) (new Uint8Array v) (let ((start (car rest))) (if (null? (cdr rest)) (v.slice start) (v.slice start (cadr rest)))))) +(define (bytevector-copy! to at from . rest) "(bytevector-copy! to at from)\u000A(bytevector-copy! to at from start)\u000A(bytevector-copy! to at from start end)\u000A\u000ACopies the bytes of bytevector from between start and end to bytevector to,\u000Astarting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1)))))) +(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) "(string->utf8 string)\u000A(string->utf8 string start)\u000A(string->utf8 string start end)\u000A\u000AFunction converts string into u8 bytevector using utf8 encoding.\u000AThe start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end))))))) +(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector)\u000A(utf8->string u8vector start)\u000A(utf8->string u8vector start end)\u000A\u000AFunction converts u8 bytevector into string using utf8 encoding.\u000AThe start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end))))))) +(define (open-input-string string) "(open-input-string string)\u000A\u000AFunction create new string port as input that can be used to\u000Aread S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment))) +(define (open-output-string) "(open-output-string)\u000A\u000AFunction create new output port that can used to write string into\u000Aand after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr)) +(define (get-output-string port) "(get-output-string port)\u000A\u000AFunction get full string from string port. If nothing was wrote\u000Ato given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString))) +(define (open-input-bytevector bytevector) "(open-input-bytevector bytevector)\u000A\u000ACreate new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector)) +(define (open-binary-input-file filename) "(open-binary-input-file filename)\u000A\u000AFunction return new Input Binary Port with given filename. In Browser\u000Auser need to provide global fs variable that is instance of FS interface." (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) (new lips.InputBinaryFilePort u8vector filename))) +(define (binary-port? port) "(binary-port? port)\u000A\u000AFunction test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary")))) +(define (textual-port? port) "(textual-port? port)\u000A\u000AFunction test if argument is string port." (and (port? port) (eq? port.__type__ (Symbol.for "text")))) +(define-macro (%define-binary-input-lambda name docstring fn) (let ((port (gensym)) (name-str (symbol->string name))) (quasiquote (define ((unquote name) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-input-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "input-port") (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port. Binary port required."))) ((unquote fn) (unquote port)))))))) +(%define-binary-input-lambda peek-u8 "(peek-u8)\u000A(peek-u8 port)\u000A\u000AReturn next byte from input-binary port. If there are no more bytes\u000Ait return eof object." (lambda (port) (port.peek_u8))) +(%define-binary-input-lambda read-u8 "(read-u8)\u000A(read-u8 port)\u000A\u000ARead next byte from input-binary port. If there are no more bytes\u000Ait return eof object." (lambda (port) (port.read_u8))) +(%define-binary-input-lambda u8-ready? "(u8-ready?)\u000A(u8-ready? port)\u000A\u000AReturns #t if a byte is ready on the binary input port and returns #f otherwise.\u000AIf u8-ready? returns #t then the next read-u8 operation on the given port is\u000Aguaranteed not to hang. If the port is at end of file then u8-ready? returns #t." (lambda (port) (port.u8_ready))) +(define (read-bytevector k . rest) "(read-bytevector k)\u000A(read-bytevector k port)\u000A\u000ARead next n bytes from input-binary port. If there are no more bytes\u000Ait returns eof object. If there are less then n bytes in port it\u000Areturn the only bytes that are available" (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-bytevector" port "input-port") (if (not (binary-port? port)) (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k)))) +(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename)\u000A\u000AFunction delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename))))))) +(define (call-with-port port proc) "(call-with-port port proc)\u000A\u000AProc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close))))) +(define (close-port port) "(close-port port)\u000A\u000AClose input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close)) +(define (eof-object) "(eof-object)\u000A\u000AProcedure returns eof object that indicate end of the port" lips.eof) +(define (output-port-open? port) "(output-port-open? port)\u000A\u000AFunction check if argument is output-port and if you can write to it." (and (output-port? port) (port.is_open))) +(define (input-port-open? port) "(input-port-open? port)\u000A\u000AFunction check if argument is input-port and if you can read from it." (and (input-port? port) (port.is_open))) +(define (flush-output-port port) "(flush-output-port port)\u000A\u000AFunctio do nothing, flush is not needed in LIPS in both NodeJS and Browser.\u000AThe function is added, so it don't throw exception when using R7RS code." (if #f #f)) +(define (write-string string . rest) "(write-string string)\u000A(write-string string port)\u000A(write-string string port start)\u000A(write-string string port start end)\u000A\u000AWrites the characters of string from start to end in left-toright order\u000Ato the textual output port." (typecheck "write-string" string "string") (let ((port (if (null? rest) (current-output-port) (car rest))) (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) (string-length string) (caddr rest)))) (typecheck "write-string" port "output-port") (typecheck "write-string" start "number") (typecheck "write-string" end "number") (display (substring string start end) port))) +(define (write-char char . rest) "(write-char string)\u000A(write-char string port)\u000A\u000AWrites the character char (not an external representation of the character)\u000Ato the given textual output port and returns an unspecified value." (typecheck "write-char" char "character") (let ((port (if (null? rest) (current-output-port) (car rest)))) (typecheck "write-char" port "output-port") (display (string char) port))) +(define (read-string k . rest) "(read-string k)\u000A(read-string k port)\u000A\u000AReads the next k characters, or as many as are available\u000Abefore the end of file, from the textual input port into a\u000Anewly allocated string in left-to-right order and returns the\u000Astring. If no characters are available before the end of file,\u000Aan end-of-file object is returned." (typecheck "read-string" k "number") (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-string" port "input-port") (port.read_string k))) +(define (list-copy obj) "(list-copy obj)\u000A\u000ACopy the object passed as argument but only if it's list. The car elements\u000Aof the list are not copied, they are passed as is." (typecheck "list-copy" obj #("pair" "nil")) (if (null? obj) obj (obj.clone #f))) +(define-macro (define-record-type name constructor pred . fields) "(define-record-type name constructor pred . fields)\u000A\u000AMacro for defining records. Example of usage:\u000A\u000A (define-record-type <pare>\u000A (kons x y)\u000A pare?\u000A (x kar set-kar!)\u000A (y kdr set-kdr!))\u000A\u000A(define p (kons 1 2))\u000A(print (kar p))\u000A;; 1\u000A(set-kdr! p 3)\u000A(print (kdr p))\u000A;; 3" (let ((class-name (gensym)) (obj-name (gensym)) (value-name (gensym))) (quasiquote (begin (define (unquote class-name) (class Object (constructor (lambda (self (unquote-splicing (cdr constructor))) (unquote-splicing (map (lambda (field) (let* ((name (symbol->string field)) (prop (string-append "self." name))) (quasiquote (set! (unquote (string->symbol prop)) (unquote field))))) (cdr constructor))))) (toType (lambda (self) "record")) (toString (lambda (self) (unquote (symbol->string name)))))) (define (unquote constructor) (new (unquote class-name) (unquote-splicing (cdr constructor)))) (define ((unquote pred) obj) (instanceof (unquote class-name) obj)) (unquote-splicing (map (lambda (field) (let ((prop-name (car field)) (get (cadr field)) (set (if (null? (cddr field)) () (caddr field)))) (quasiquote (begin (define ((unquote get) (unquote obj-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (. (unquote obj-name) (quote (unquote prop-name))))) (unquote (if (not (null? set)) (quasiquote (define ((unquote set) (unquote obj-name) (unquote value-name)) (typecheck (unquote (symbol->string get)) (unquote obj-name) "record") (if (not ((unquote pred) (unquote obj-name))) (throw (new Error (unquote (string-append "object is not record of type " (symbol->string name))))) (set-obj! (unquote obj-name) (quote (unquote prop-name)) (unquote value-name))))))))))) fields)))))) +(define (nan? x) "(nan? x)\u000A\u000AFunction check if argument x is Not a Number (NaN) value." (and (number? x) (or (x.isNaN) (and (%number-type "complex" x) (or (nan? (real-part x)) (nan? (imag-part x))))))) +(define (infinite? x) "(infinite? x)\u000A\u000AFunction check if value is infinite." (or (eq? x Number.NEGATIVE_INFINITY) (eq? x Number.POSITIVE_INFINITY) (and (number? x) (not (eq? x NaN)) (%number-type "complex" x) (or (infinite? (real-part x)) (infinite? (imag-part x)))))) +(define (finite? x) "(finite? x)\u000A\u000AFunction check if value is finite." (not (infinite? x))) +(define-class %Library Object (constructor (lambda (self name) (set! self.__namespace__ &()) (set! self.__name__ name))) (append (lambda (self namespace env) (if (environment? (. self.__namespace__ namespace)) (throw (new Error (string-append "namespace " namespace " already exists in library " self.__name__))) (set-obj! self.__namespace__ namespace env)))) (env (lambda (self namespace) (let ((env (. self.__namespace__ namespace))) (if (not (environment? env)) (throw (new Error (string-append "namespace " namespace " sdon't exists"))) env)))) (get (lambda (self namespace name) (--> (self.env namespace) (get name)))) (set (lambda (self namespace name value) (--> (self.env namespace) (set name value)))) (toString (lambda (self) (string-append "#<Library(" self.__name__ ")>")))) +(define (%import-name library namespace names) (quasiquote (begin (unquote-splicing (map (lambda (name) (quasiquote (define (unquote name) (--> (unquote library) (get (quote (unquote namespace)) (quote (unquote name))))))) names))))) +(define-macro (import . specs) "(import (library namespace))\u000A(import (only (library namespace) name1 name2))\u000A\u000AMacro for importing names from library." (let ((parent (current-environment))) (quasiquote (begin (unquote-splicing (map (lambda (spec) (if (not (pair? spec)) (throw (new Error "import: invalid syntax")) (cond ((symbol=? (car spec) (quote only)) (let ((lib (caadr spec)) (namespace (caaddr spec))) (if (pair? (cadr spec)) (%import-name (unquote lib) (quote (unquote namespace)) (quote (unquote (caddr spec)))) (throw (new Error "import: invalid syntax"))))) (else (let* ((lib-name (car spec)) (lib (parent.get lib-name)) (namespace (cadr spec))) (%import-name lib-name namespace (env (lib.env namespace)))))))) specs)))))) +(define (new-library name namespace) "(new-library name)\u000A\u000ACreate new empty library object with empty namespace." (let* ((parent (. (current-environment) (quote __parent__))) (lib (let ((lib (--> parent (get name &(:throwError #f))))) (if (null? lib) (new %Library name) lib))) (x (new lips.Environment (string-append "library-" (--> name (toLowerCase)) "-" (--> namespace (toLowerCase)))))) (lib.append namespace x) lib)) +(define (%export module namespace specs) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) specs))))) +(define-macro (define-library spec . body) "(define-library (library (name namespace) . body)\u000A\u000AMacro for defining modules inside you can use define to create functions.\u000AAnd use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) +(define-values (current-directory set-current-directory!) (if (eq? self window) (let ((cwd (string-append location.origin (--> location.pathname (replace #/\/[^/]+$/ "/"))))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's corrent URL." cwd) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (set! cwd value)))) (let ((process (require "process"))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's path from where\u000Athe script was executed." (string-append (process.cwd) "/")) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (process.chdir value)))))) diff --git a/scripts/minify.scm b/scripts/minify.scm index 6b4ed93c..405243fc 100755 --- a/scripts/minify.scm +++ b/scripts/minify.scm @@ -1,9 +1,15 @@ #!/usr/bin/env lips +(define (dump expr) + (let ((result (open-output-string))) + (write expr result) + (display (--> (get-output-string result) + (replace #/\n/g "\\xA;"))) + (newline) + (close-port result))) + (if (= process.argv.length 4) - (let* ((fs (require "fs")) - (buff (fs.promises.readFile (. process.argv 3))) - (port (open-input-string (--> buff (toString))))) - (do ((expr (read port) (read port))) - ((eq? expr eof)) - (write expr)))) \ No newline at end of file + (let ((port (open-input-file (. process.argv 3)))) + (do ((expr (read port) (read port))) + ((eof-object? expr)) + (dump expr)))) \ No newline at end of file From dbbd7d5a4c7e3f83fc41773b64949f6928cfb423 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 16:44:20 +0100 Subject: [PATCH 073/109] fix lint errors --- README.md | 4 ++-- dist/lips.js | 47 +++++++++++++++++++++++++++++++++-------------- dist/lips.min.js | 4 ++-- src/lips.js | 10 +++++----- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index c5b4e2b2..7e96b3d9 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&102de4ade46b09bbed7c4c1010ebac7ad1e01433)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&086bf7f3991d67123193784c9453ae9a)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&239cf2966e9c02888eac8b28dd342c77171f8990)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&6e88ba0e98bc08e926af51e1a69cc377)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 0fc16260..dc9a8ed9 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 12:42:34 +0000 + * build: Wed, 03 Mar 2021 15:41:17 +0000 */ (function () { 'use strict'; @@ -3576,13 +3576,39 @@ return 0; } // ---------------------------------------------------------------------- + // :: token based pattern matching (used by formatter) + // ---------------------------------------------------------------------- + + /* + function nested_pattern(pattern) { + return pattern instanceof Array || + pattern instanceof Pattern; + } + */ + // ---------------------------------------------------------------------- function match(pattern, input) { return inner_match(pattern, input) === input.length; function inner_match(pattern, input) { - + /* + function empty_match() { + if (p <= 0 && i <= 0) { + return false; + } + var prev_pattern = pattern[p - 1]; + if (!nested_pattern(prev_pattern)) { + prev_pattern = [prev_pattern]; + } + var next_pattern = pattern[p + 1]; + if (next_pattern && !nested_pattern(next_pattern)) { + next_pattern = [next_pattern]; + } + return match(prev_pattern, [input[i - 1]]) && + (!next_pattern || match(next_pattern, [input[i]])); + } + */ function not_symbol_match() { return pattern[p] === Symbol["for"]('symbol') && !is_symbol_string(input[i]); } @@ -3600,11 +3626,6 @@ var glob = {}; for (var i = 0; i < input.length; ++i) { - log({ - input: input[i], - pattern: pattern[p] - }); - if (typeof pattern[p] === 'undefined') { return i; } @@ -3906,7 +3927,8 @@ var p_o = /[[(]/; var p_e = /[\])]/; var not_p = /[^()[\]]/; - var not_close = new Ahead(/[^)\]]/); + var not_close = new Ahead(/[^)\]]/); //const open = new Ahead(/[([]/); + var glob = Symbol["for"]('*'); var sexp = new Pattern([p_o, glob, p_e], '+'); var symbol = new Pattern([Symbol["for"]('symbol')], '?'); @@ -3957,9 +3979,6 @@ } var sub = tokens.slice(0, i); - - if (sub.join('') === '(let ((xxx (if (null? rest) (current-input-port) (car rest))) ') ; - var sexp = {}; rules.map(function (b) { return b[1]; @@ -13451,10 +13470,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 03 Mar 2021 12:42:34 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Wed, 03 Mar 2021 15:41:17 +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('Wed, 03 Mar 2021 12:42:34 +0000').valueOf(); + var date = LString('Wed, 03 Mar 2021 15:41:17 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13494,7 +13513,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 03 Mar 2021 12:42:34 +0000', + date: 'Wed, 03 Mar 2021 15:41:17 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 3975673b..3007a795 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 12:42:34 +0000 + * build: Wed, 03 Mar 2021 15:19:29 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){log({input:n[u],pattern:t[i]});if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);if(a.join("")==="(let ((xxx (if (null? rest) (current-input-port) (car rest))) ");var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 12:42:34 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 12:42:34 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){log({input:n[u],pattern:t[i]});if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);if(a.join("")==="(let ((xxx (if (null? rest) (current-input-port) (car rest))) ");var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 15:19:29 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 15:19:29 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index 95bc6410..2656b8ab 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1641,14 +1641,17 @@ // ---------------------------------------------------------------------- // :: token based pattern matching (used by formatter) // ---------------------------------------------------------------------- + /* function nested_pattern(pattern) { return pattern instanceof Array || pattern instanceof Pattern; } + */ // ---------------------------------------------------------------------- function match(pattern, input) { return inner_match(pattern, input) === input.length; function inner_match(pattern, input) { + /* function empty_match() { if (p <= 0 && i <= 0) { return false; @@ -1664,6 +1667,7 @@ return match(prev_pattern, [input[i - 1]]) && (!next_pattern || match(next_pattern, [input[i]])); } + */ function not_symbol_match() { return pattern[p] === Symbol.for('symbol') && !is_symbol_string(input[i]); } @@ -1677,7 +1681,6 @@ var p = 0; var glob = {}; for (var i = 0; i < input.length; ++i) { - log({input: input[i], pattern: pattern[p]}); if (typeof pattern[p] === 'undefined') { return i; } @@ -1920,7 +1923,7 @@ var p_e = /[\])]/; var not_p = /[^()[\]]/; const not_close = new Ahead(/[^)\]]/); - const open = new Ahead(/[([]/); + //const open = new Ahead(/[([]/); const glob = Symbol.for('*'); const sexp = new Pattern([p_o, glob, p_e], '+'); const symbol = new Pattern([Symbol.for('symbol')], '?'); @@ -1971,9 +1974,6 @@ continue; } var sub = tokens.slice(0, i); - if (sub.join('') === '(let ((xxx (if (null? rest) (current-input-port) (car rest))) ') { - //debugger; - } var sexp = {}; rules.map(b => b[1]).forEach(count => { count = count.valueOf(); From debbdabb96bf1dd62effa0268b9701159b222b0d Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Wed, 3 Mar 2021 17:13:49 +0100 Subject: [PATCH 074/109] fix bookmark css for underjord.io website The problem was that the website use display: flex on nav and this make the close button aligned to the left --- lib/css/terminal.css | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/css/terminal.css b/lib/css/terminal.css index 6e2f2186..9a6f0069 100644 --- a/lib/css/terminal.css +++ b/lib/css/terminal.css @@ -50,6 +50,7 @@ margin: 0; width: 100%; height: auto; + display: block; } .shell-container { position: fixed; From 883a252c53a0e15e19b936912b9cc9249f295455 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 09:46:14 +0100 Subject: [PATCH 075/109] fix division of complex with non complex #34 This fixes division of complex that have +nan.0 or +inf.0 in on of the parts divided by non complex value. --- README.md | 4 ++-- dist/lips.js | 26 +++++++++++++++++--------- dist/lips.min.js | 4 ++-- src/lips.js | 7 ++++++- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 7e96b3d9..362b3a38 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&239cf2966e9c02888eac8b28dd342c77171f8990)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&6e88ba0e98bc08e926af51e1a69cc377)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&debbdabb96bf1dd62effa0268b9701159b222b0d)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&086bf7f3991d67123193784c9453ae9a)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index dc9a8ed9..6bb2a2aa 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 15:41:17 +0000 + * build: Thu, 04 Mar 2021 08:46:05 +0000 */ (function () { 'use strict'; @@ -7986,9 +7986,17 @@ LComplex.prototype.div = function (n) { if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { - n = LComplex({ - im: 0, - re: n + if (!(n instanceof LNumber)) { + n = LNumber(n); + } + + var _re = this.__re__.div(n); + + var _im = this.__im__.div(n); + + return LComplex({ + re: _re, + im: _im }); } else if (!LNumber.isComplex(n)) { throw new Error('[LComplex::div] Invalid value'); @@ -8060,10 +8068,10 @@ n = LNumber(n); } - var _im = n.asType(0); + var _im2 = n.asType(0); n = { - __im__: _im, + __im__: _im2, __re__: n }; } else if (!LNumber.isComplex(n)) { @@ -13470,10 +13478,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Wed, 03 Mar 2021 15:41:17 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 04 Mar 2021 08:46:05 +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('Wed, 03 Mar 2021 15:41:17 +0000').valueOf(); + var date = LString('Thu, 04 Mar 2021 08:46:05 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13513,7 +13521,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Wed, 03 Mar 2021 15:41:17 +0000', + date: 'Thu, 04 Mar 2021 08:46:05 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 3007a795..318cfce4 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Wed, 03 Mar 2021 15:19:29 +0000 + * build: Thu, 04 Mar 2021 08:46:05 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){log({input:n[u],pattern:t[i]});if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);if(a.join("")==="(let ((xxx (if (null? rest) (current-input-port) (car rest))) ");var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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)){e=LComplex({im:0,re:e})}else if(!LNumber.isComplex(e)){throw new Error("[LComplex::div] Invalid value")}var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];var a=LComplex({re:i.__re__,im:i.__im__.sub()});var u=i.factor();var o=n.mul(a);var c=o.__re__.op("/",u);var s=o.__im__.op("/",u);return LComplex({re:c,im:s})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Wed, 03 Mar 2021 15:19:29 +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,") <https://lips.js.org>\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:"Wed, 03 Mar 2021 15:19:29 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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=LComplex({re:u.__re__,im:u.__im__.sub()});var c=u.factor();var s=a.mul(o);var l=s.__re__.op("/",c);var f=s.__im__.op("/",c);return LComplex({re:l,im:f})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 08:46:05 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 08:46:05 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index 2656b8ab..0eb5310c 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5014,7 +5014,12 @@ // ------------------------------------------------------------------------- LComplex.prototype.div = function(n) { if (LNumber.isNumber(n) && !LNumber.isComplex(n)) { - n = LComplex({ im: 0, re: n }); + if (!(n instanceof LNumber)) { + n = LNumber(n); + } + const re = this.__re__.div(n); + const im = this.__im__.div(n); + return LComplex({ re, im }); } else if (!LNumber.isComplex(n)) { throw new Error('[LComplex::div] Invalid value'); } From 425bc144bbd1cb36453091ccf3a23d82e0d7e370 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 10:14:31 +0100 Subject: [PATCH 076/109] fix auto indent in Web REPL on paste #136 --- lib/js/terminal.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) mode change 100644 => 100755 lib/js/terminal.js diff --git a/lib/js/terminal.js b/lib/js/terminal.js old mode 100644 new mode 100755 index 4bffcf84..5fa6ccde --- a/lib/js/terminal.js +++ b/lib/js/terminal.js @@ -168,15 +168,10 @@ function terminal({selector, lips, dynamic = false, name = 'terminal'}, undefine var formatter = new lips.Formatter(code); if (!code.match(/\n/)) { formatter.break(); - output = formatter.format({ - offset: prompt.length - }); - } else { - var space = new Array(prompt.length + 1).join(' '); - output = code.split('\n').map(function(line, i) { - return (i === 0 ? '' : space) + line; - }).join('\n'); } + output = formatter.format({ + offset: prompt.length + }); } catch(e) { console.log(e); // boken LIPS code From 5a74bd7437980ecdbae654160d3cd931971730ea Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 12:08:01 +0100 Subject: [PATCH 077/109] fix division on single argument #34 now `(/ n)` == `(/ 1 n)` --- CHANGELOG.md | 2 ++ README.md | 4 ++-- dist/lips.js | 60 ++++++++++++++++++++++++++++++----------------- dist/lips.min.js | 4 ++-- src/lips.js | 22 ++++++++++++----- tests/numbers.scm | 6 +++++ 6 files changed, 66 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ecaa1bb..328e5b5a 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * new `environment?` function * add `current-directory` and `set-...` from SRFI-170 * add gensym literals (e.g. `#:foo`) +* fix pretty print of different cases of `let` ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string @@ -37,6 +38,7 @@ * fix arithmetic with single complex value * fix parsing regex that have escape slash and parenthesis (`#/( \\/)/g`) * fix parsing regex that have single slash in class brackets (`#/\/[^/]+$/`) +* fix division on single argument (now `(/ n)` == `(/ 1 n)`) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 362b3a38..9f131013 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&debbdabb96bf1dd62effa0268b9701159b222b0d)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&086bf7f3991d67123193784c9453ae9a)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&425bc144bbd1cb36453091ccf3a23d82e0d7e370)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&88281233a766560699f94ea9d4ce48f5)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 6bb2a2aa..1927e815 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 08:46:05 +0000 + * build: Thu, 04 Mar 2021 11:05:36 +0000 */ (function () { 'use strict'; @@ -12063,11 +12063,27 @@ return LNumber(a).sub(b); })); } - }, "(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."), + }, "(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."), // ------------------------------------------------------------------ - '/': doc('/', reduceMathOp(function (a, b) { - return LNumber(a).div(b); - }), "(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."), + '/': doc('/', function () { + for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { + args[_key37] = arguments[_key37]; + } + + if (args.length === 0) { + throw new Error('/: procedure require at least one argument'); + } + + typecheck_args('/', args, 'number'); + + if (args.length === 1) { + return LNumber(1).div(args[0]); + } + + return args.reduce(binaryMathOp(function (a, b) { + return LNumber(a).div(b); + })); + }, "(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."), // ------------------------------------------------------------------ abs: doc('abs', singleMathOp(function (n) { return LNumber(n).abs(); @@ -12117,8 +12133,8 @@ // ------------------------------------------------------------------ // Booleans '==': doc('==', function () { - for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { - args[_key37] = arguments[_key37]; + for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { + args[_key38] = arguments[_key38]; } typecheck_args('==', args, 'number'); @@ -12128,8 +12144,8 @@ }, "(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"), // ------------------------------------------------------------------ '>': doc('>', function () { - for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { - args[_key38] = arguments[_key38]; + for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { + args[_key39] = arguments[_key39]; } typecheck_args('>', args, 'number'); @@ -12139,8 +12155,8 @@ }, "(> x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"), // ------------------------------------------------------------------ '<': doc('<', function () { - for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { - args[_key39] = arguments[_key39]; + for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { + args[_key40] = arguments[_key40]; } typecheck_args('<', args, 'number'); @@ -12150,8 +12166,8 @@ }, "(< x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"), // ------------------------------------------------------------------ '<=': doc(function () { - for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { - args[_key40] = arguments[_key40]; + for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { + args[_key41] = arguments[_key41]; } typecheck_args('<=', args, 'number'); @@ -12161,8 +12177,8 @@ }, "(<= x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"), // ------------------------------------------------------------------ '>=': doc('>=', function () { - for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { - args[_key41] = arguments[_key41]; + for (var _len41 = arguments.length, args = new Array(_len41), _key42 = 0; _key42 < _len41; _key42++) { + args[_key42] = arguments[_key42]; } typecheck_args('>=', args, 'number'); @@ -12574,11 +12590,11 @@ for (var _i5 = 0, _Object$entries2 = Object.entries(mapping); _i5 < _Object$entries2.length; _i5++) { var _Object$entries2$_i = slicedToArray(_Object$entries2[_i5], 2), - _key42 = _Object$entries2$_i[0], + _key43 = _Object$entries2$_i[0], value = _Object$entries2$_i[1]; if (obj instanceof value) { - return _key42; + return _key43; } } @@ -12827,8 +12843,8 @@ args = args.map(function (arg) { if (is_lips_function(arg)) { var wrapper = function wrapper() { - for (var _len41 = arguments.length, args = new Array(_len41), _key43 = 0; _key43 < _len41; _key43++) { - args[_key43] = arguments[_key43]; + for (var _len42 = arguments.length, args = new Array(_len42), _key44 = 0; _key44 < _len42; _key44++) { + args[_key44] = arguments[_key44]; } return unpromise(arg.apply(this, args), unbox); @@ -13478,10 +13494,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 04 Mar 2021 08:46:05 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 04 Mar 2021 11:05:36 +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('Thu, 04 Mar 2021 08:46:05 +0000').valueOf(); + var date = LString('Thu, 04 Mar 2021 11:05:36 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13521,7 +13537,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 04 Mar 2021 08:46:05 +0000', + date: 'Thu, 04 Mar 2021 11:05:36 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 318cfce4..e658aef8 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 08:46:05 +0000 + * build: Thu, 04 Mar 2021 11:05:36 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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=LComplex({re:u.__re__,im:u.__im__.sub()});var c=u.factor();var s=a.mul(o);var l=s.__re__.op("/",c);var f=s.__im__.op("/",c);return LComplex({re:l,im:f})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n1)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",reduceMathOp(function(e,r){return LNumber(e).div(r)}),"(/ . numbers)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will return that value."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 08:46:05 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 08:46:05 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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=LComplex({re:u.__re__,im:u.__im__.sub()});var c=u.factor();var s=a.mul(o);var l=s.__re__.op("/",c);var f=s.__im__.op("/",c);return LComplex({re:l,im:f})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 11:05:36 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 11:05:36 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index 0eb5310c..19b93a34 100644 --- a/src/lips.js +++ b/src/lips.js @@ -8438,17 +8438,27 @@ })); } }, `(- n1 n2 ...) - (- n1) + (- n) Substract number passed as argument. If only one argument is passed it will negate the value.`), // ------------------------------------------------------------------ - '/': doc('/', reduceMathOp(function(a, b) { - return LNumber(a).div(b); - }), `(/ . numbers) + '/': doc('/', function(...args) { + if (args.length === 0) { + throw new Error('/: procedure require at least one argument'); + } + typecheck_args('/', args, 'number'); + if (args.length === 1) { + return LNumber(1).div(args[0]); + } + return args.reduce(binaryMathOp(function(a, b) { + return LNumber(a).div(b); + })); + }, `(/ n1 n2 ...) + (/ n) - Divide number passed as arguments one by one. If single argument - is passed it will return that value.`), + Divide number passed as arguments one by one. If single argument + is passed it will calculate (/ 1 n1).`), // ------------------------------------------------------------------ abs: doc('abs', singleMathOp(function(n) { return LNumber(n).abs(); diff --git a/tests/numbers.scm b/tests/numbers.scm index 81d746e4..649c9709 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -555,6 +555,12 @@ (test "numbers: operators /" (lambda (t) + ;; single arg + (t.is (/ 10) 1/10) + (t.is (/ 10.0) 0.1) + (t.is (/ 1/10) 10) + (t.is (/ 10+10i) 1/20-1/20i) + (t.is (/ 10 10) 1) (t.is (/ 10 1/10) 100) (t.is (/ 10 2) 5) From b79b4fcc0c53bf8e6e46e2278500316693bd0ed3 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 12:54:02 +0100 Subject: [PATCH 078/109] better example in --> docstring --- dist/std.min.scm | 2 +- dist/std.scm | 6 +++++- lib/bootstrap.scm | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) mode change 100644 => 100755 lib/bootstrap.scm diff --git a/dist/std.min.scm b/dist/std.min.scm index 5d7535ce..ede74872 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -3,7 +3,7 @@ (define-macro (letrec-syntax vars . body) "(letrec-syntax ((name fn)) body)\u000A\u000A Macro works like combination of letrec and define-syntax. It creaates\u000A local macros and evaluate body in context of those macros." (quasiquote (letrec (unquote vars) (unquote-splicing (map (lambda (rule) (quasiquote (typecheck "letrec-syntax" (unquote (car rule)) "syntax"))) vars)) (unquote-splicing body)))) (define-macro (define-syntax name expr . rest) "(define-syntax name expression [__doc__])\u000A\u000AMacro define new hygienic macro using syntax-rules with optional documentation" (let ((expr-name (gensym "expr-name"))) (quasiquote (define (unquote name) (let (((unquote expr-name) (unquote expr))) (typecheck "define-syntax" (unquote expr-name) "syntax") (unquote expr-name)) (unquote-splicing rest))))) (define (quoted-symbol? x) "(quoted-symbol? code)\u000A\u000AHelper function that test if value is quoted symbol. To be used in macros\u000Athat pass literal code that is transformed by parser.\u000A\u000Ausage:\u000A\u000A (define-macro (test x)\u000A (if (quoted-symbol? x)\u000A `',(cadr x)))\u000A\u000A (list 'hello (test 'world))" (and (pair? x) (eq? (car x) (quote quote)) (symbol? (cadr x)) (null? (cddr x)))) -(define-macro (--> expr . code) "Helper macro that simplify calling methods on objects. It work with chaining\u000A\u000Ausage: (--> ($ \"body\")\u000A (css \"color\" \"red\")\u000A (on \"click\" (lambda () (display \"click\"))))\u000A\u000A (--> document (querySelectorAll \"div\"))\u000A (--> (fetch \"https://jcubic.pl\")\u000A (text)\u000A (match #/<title>([^<]+)<\\/title>/)\u000A 1)\u000A (--> document\u000A (querySelectorAll \".cmd-prompt\")\u000A 0\u000A \"innerText\")\u000A (--> document.body\u000A (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) (quasiquote (let* (((unquote obj) (unquote expr))) (unquote-splicing (map (lambda (code) (let ((value (gensym "value"))) (quasiquote (let* (((unquote value) (unquote (let ((name (cond ((quoted-symbol? code) (symbol->string (cadr code))) ((pair? code) (symbol->string (car code))) (#t code)))) (if (string? name) (quasiquote (. (unquote obj) (unquote-splicing (split "." name)))) (quasiquote (. (unquote obj) (unquote name)))))))) (unquote (if (and (pair? code) (not (quoted-symbol? code))) (quasiquote (set! (unquote obj) ((unquote value) (unquote-splicing (cdr code))))) (quasiquote (set! (unquote obj) (unquote value))))))))) code)) (unquote obj))))) +(define-macro (--> expr . code) "Helper macro that simplify calling methods on objects. It work with chaining\u000A\u000Ausage: (--> ($ \"body\")\u000A (css \"color\" \"red\")\u000A (on \"click\" (lambda () (display \"click\"))))\u000A\u000A (--> document (querySelectorAll \"div\"))\u000A\u000A (--> (fetch \"https://jcubic.pl\")\u000A (text)\u000A (match #/<title>([^<]+)<\\/title>/)\u000A 1)\u000A \u000A (--> document\u000A (querySelectorAll \".cmd-prompt\")\u000A 0\u000A 'innerHTML\u000A (replace #/<(\"[^\"]+\"|[^>])+>/g \"\"))\u000A\u000A (--> document.body\u000A (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) (quasiquote (let* (((unquote obj) (unquote expr))) (unquote-splicing (map (lambda (code) (let ((value (gensym "value"))) (quasiquote (let* (((unquote value) (unquote (let ((name (cond ((quoted-symbol? code) (symbol->string (cadr code))) ((pair? code) (symbol->string (car code))) (#t code)))) (if (string? name) (quasiquote (. (unquote obj) (unquote-splicing (split "." name)))) (quasiquote (. (unquote obj) (unquote name)))))))) (unquote (if (and (pair? code) (not (quoted-symbol? code))) (quasiquote (set! (unquote obj) ((unquote value) (unquote-splicing (cdr code))))) (quasiquote (set! (unquote obj) (unquote value))))))))) code)) (unquote obj))))) (define-macro (define-global first . rest) "(define-global var value)\u000A(define-global (name . args) body)\u000A\u000AMacro that define functions or variables in global context, so they can be used\u000Ainside let and get let variables in closure, Useful for universal macros." (if (pair? first) (let ((name (car first))) (quasiquote (--> lips.env (set (unquote (symbol->string name)) (lambda (unquote (cdr first)) (unquote-splicing rest)))))) (quasiquote (--> lips.env (set (unquote (symbol->string first)) (unquote (car rest))))))) (define-macro (globalize expr . rest) "(globalize expr)\u000A\u000A Macro will get the value of the expression and add each method as function to global\u000A scope." (let* ((env (current-environment)) (obj (eval expr env)) (name (gensym "name")) (env-name (gensym "env-name")) (make-name (if (pair? rest) (let ((pre (symbol->string (car rest)))) (lambda (name) (string->symbol (concat pre name)))) string->symbol))) (quasiquote (let (((unquote name) (unquote expr))) (unquote-splicing (filter pair? (map (lambda (key) (if (and (not (match /^_/ key)) (function? (. obj key))) (let* ((args (gensym "args"))) (quasiquote (define-global ((unquote (make-name key)) unquote args) (apply (. (unquote name) (unquote key)) (unquote args))))))) (array->list (--> Object (keys obj)))))))))) (define (single list) "(single list)\u000A\u000AFunction check if argument is list with single element" (and (pair? list) (not (cdr list)))) diff --git a/dist/std.scm b/dist/std.scm index 5185beb9..de010641 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -82,14 +82,18 @@ (on \"click\" (lambda () (display \"click\")))) (--> document (querySelectorAll \"div\")) + (--> (fetch \"https://jcubic.pl\") (text) (match #/<title>([^<]+)<\\/title>/) 1) + (--> document (querySelectorAll \".cmd-prompt\") 0 - \"innerText\") + 'innerHTML + (replace #/<(\"[^\"]+\"|[^>])+>/g \"\")) + (--> document.body (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm old mode 100644 new mode 100755 index d4156434..8b1027ac --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -82,14 +82,18 @@ (on \"click\" (lambda () (display \"click\")))) (--> document (querySelectorAll \"div\")) + (--> (fetch \"https://jcubic.pl\") (text) (match #/<title>([^<]+)<\\/title>/) 1) + (--> document (querySelectorAll \".cmd-prompt\") 0 - \"innerText\") + 'innerHTML + (replace #/<(\"[^\"]+\"|[^>])+>/g \"\")) + (--> document.body (style.setProperty \"--color\" \"red\"))" (let ((obj (gensym "obj"))) From 0338544c71c80f84833c1365a6edf570f1fb8064 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 13:52:56 +0100 Subject: [PATCH 079/109] fix complex operation that result in real #34 --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 34 +++++++++++++++++++++------------- dist/lips.min.js | 4 ++-- src/lips.js | 18 ++++++++++++------ tests/numbers.scm | 6 +++++- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 328e5b5a..0adf99ab 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ * fix parsing regex that have escape slash and parenthesis (`#/( \\/)/g`) * fix parsing regex that have single slash in class brackets (`#/\/[^/]+$/`) * fix division on single argument (now `(/ n)` == `(/ 1 n)`) +* fix complex operation that result in real (e.g. multiplication over conjugation) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 9f131013..4ca1556e 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&425bc144bbd1cb36453091ccf3a23d82e0d7e370)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&88281233a766560699f94ea9d4ce48f5)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&b79b4fcc0c53bf8e6e46e2278500316693bd0ed3)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&f023d70c9b69774030a250f75064ef33)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 1927e815..b1d73f5f 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 11:05:36 +0000 + * build: Thu, 04 Mar 2021 11:45:43 +0000 */ (function () { 'use strict'; @@ -7955,6 +7955,14 @@ }; // ------------------------------------------------------------------------- + LComplex.prototype.conjugate = function () { + return LComplex({ + re: this.__re__, + im: this.__im__.sub() + }); + }; // ------------------------------------------------------------------------- + + LComplex.prototype.sqrt = function () { var r = this.modulus(); // code based ok Kawa Scheme source code (file DComplex.java) // Copyright (c) 1997 Per M.A. Bothner. @@ -8007,12 +8015,8 @@ a = _this$coerce6[0], b = _this$coerce6[1]; - var conj = LComplex({ - re: b.__re__, - im: b.__im__.sub() - }); var denom = b.factor(); - var num = a.mul(conj); + var num = a.mul(b.conjugate()); var re = num.__re__.op('/', denom); @@ -8050,13 +8054,17 @@ var _this5 = this; var calc = function calc(re, im) { - var ret = fn(_this5.__re__, re, _this5.__im__, im); + var result = fn(_this5.__re__, re, _this5.__im__, im); + + if ('im' in result && 're' in result) { + if (result.im.cmp(0) === 0 && !LNumber.isFloat(result.im)) { + return result.re; + } - if ('im' in ret && 're' in ret) { - return LComplex(ret, true); + return LComplex(result, true); } - return ret; + return result; }; if (typeof n === 'undefined') { @@ -13494,10 +13502,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 04 Mar 2021 11:05:36 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 04 Mar 2021 11:45:43 +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('Thu, 04 Mar 2021 11:05:36 +0000').valueOf(); + var date = LString('Thu, 04 Mar 2021 11:45:43 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13537,7 +13545,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 04 Mar 2021 11:05:36 +0000', + date: 'Thu, 04 Mar 2021 11:45:43 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index e658aef8..b8fee5f5 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 11:05:36 +0000 + * build: Thu, 04 Mar 2021 11:45:43 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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.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=LComplex({re:u.__re__,im:u.__im__.sub()});var c=u.factor();var s=a.mul(o);var l=s.__re__.op("/",c);var f=s.__im__.op("/",c);return LComplex({re:l,im:f})};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){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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 11:05:36 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 11:05:36 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 11:45:43 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 11:45:43 +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,InputBinaryFilePort:InputBinaryFilePort,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/src/lips.js b/src/lips.js index 19b93a34..302d3ef6 100644 --- a/src/lips.js +++ b/src/lips.js @@ -4991,6 +4991,10 @@ return this.factor().sqrt(); }; // ------------------------------------------------------------------------- + LComplex.prototype.conjugate = function() { + return LComplex({ re: this.__re__, im: this.__im__.sub() }); + }; + // ------------------------------------------------------------------------- LComplex.prototype.sqrt = function() { const r = this.modulus(); // code based ok Kawa Scheme source code (file DComplex.java) @@ -5024,9 +5028,8 @@ throw new Error('[LComplex::div] Invalid value'); } const [ a, b ] = this.coerce(n); - const conj = LComplex({ re: b.__re__, im: b.__im__.sub() }); const denom = b.factor(); - const num = a.mul(conj); + const num = a.mul(b.conjugate()); const re = num.__re__.op('/', denom); const im = num.__im__.op('/', denom); return LComplex({ re, im }); @@ -5053,11 +5056,14 @@ // ------------------------------------------------------------------------- LComplex.prototype.complex_op = function(name, n, fn) { const calc = (re, im) => { - var ret = fn(this.__re__, re, this.__im__, im); - if ('im' in ret && 're' in ret) { - return LComplex(ret, true); + var result = fn(this.__re__, re, this.__im__, im); + if ('im' in result && 're' in result) { + if (result.im.cmp(0) === 0 && !LNumber.isFloat(result.im)) { + return result.re; + } + return LComplex(result, true); } - return ret; + return result; }; if (typeof n === 'undefined') { return calc(); diff --git a/tests/numbers.scm b/tests/numbers.scm index 649c9709..4e0f89b7 100644 --- a/tests/numbers.scm +++ b/tests/numbers.scm @@ -661,7 +661,11 @@ (t.is (* 1.0 1/2+1/2i) 0.5+0.5i) (t.is (* 1.0 1/2+1.0i) 0.5+1.0i) - (t.is (* 1.0 1/2+1i) 0.5+1.0i))) + (t.is (* 1.0 1/2+1i) 0.5+1.0i) + ;; complex multiplication over conjugation + (t.is (* 10+10i 10-10i) 200) + (t.is (* 10+10.0i 10-10.0i) 200.0+0.0i) + (t.is (* 10+1/2i 10-1/2i) 401/4))) (test "numbers: sqrt" (lambda (t) From 04f617f0a20eeaccbef5149a74fa16370edadb96 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 4 Mar 2021 15:22:20 +0100 Subject: [PATCH 080/109] fix `list-ref` according to R7RS errata --- CHANGELOG.md | 1 + dist/std.min.scm | 2 +- dist/std.scm | 3 ++- lib/R5RS.scm | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0adf99ab..3e2a5838 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ * fix parsing regex that have single slash in class brackets (`#/\/[^/]+$/`) * fix division on single argument (now `(/ n)` == `(/ 1 n)`) * fix complex operation that result in real (e.g. multiplication over conjugation) +* fix `list-ref` according to R7RS errata ## 1.0.0-beta.11 ### Breaking diff --git a/dist/std.min.scm b/dist/std.min.scm index ede74872..39358233 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -157,7 +157,7 @@ (define (modulo a b) "(modulo a b)\u000A\u000AFunction return modulo operation on it's argumennts." (typecheck "modulo" a "number" 1) (typecheck "modulo" b "number" 2) (- a (* b (floor (/ a b))))) (define (remainder__ a b) "(modulo a b)\u000A\u000AFunction return reminder from division operation." (typecheck "remainder" a "number" 1) (typecheck "remainder" b "number" 2) (- a (* b (truncate (/ a b))))) (define (list-tail l k) "(list-tail list k)\u000A\u000AReturns the sublist of list obtained by omitting the first k elements." (typecheck "list-tail" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-tail: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) l))) -(define (list-ref l k) "(list-ref list n)\u000A\u000AReturns n element of a list." (typecheck "list-ref" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (null? l) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l))))) +(define (list-ref l k) "(list-ref list n)\u000A\u000AReturns n element of a list." (typecheck "list-ref" l (quote ("pair" "nil"))) (if (< k 0) (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) (if (or (null? (cdr l)) (null? l)) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l))))) (define (not x) "(not x)\u000A\u000AFunction return true if value is false and false otherwise." (if x #f #t)) (define (rationalize number tolerance) "(rationalize number tolerance)\u000A\u000AFunction returns simplest rational number differing from number by no more\u000Athan the tolerance." (typecheck "rationalize" number "number" 1) (typecheck "rationalize" tolerance "number" 2) (lips.rationalize number tolerance)) (define (%mem/search access op obj list) "(%member obj list function)\u000A\u000AHelper method to get first list where car equal to obj\u000Ausing provied functions as comparator." (if (null? list) #f (if (op (access list) obj) list (%mem/search access op obj (cdr list))))) diff --git a/dist/std.scm b/dist/std.scm index de010641..c0676cee 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1850,13 +1850,14 @@ (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) - (if (null? l) + (if (or (null? (cdr l)) (null? l)) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l))))) + ;; ----------------------------------------------------------------------------- (define (not x) "(not x) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 99ae3661..05941ac6 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -487,13 +487,14 @@ (throw (new Error "list-ref: index out of range")) (let ((l l) (k k)) (while (> k 0) - (if (null? l) + (if (or (null? (cdr l)) (null? l)) (throw (new Error "list-ref: not enough elements in the list"))) (set! l (cdr l)) (set! k (- k 1))) (if (null? l) l (car l))))) + ;; ----------------------------------------------------------------------------- (define (not x) "(not x) From 866a2e8cd2a815a99da8a2b49a33ed31454f5ae7 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 5 Mar 2021 17:31:44 +0100 Subject: [PATCH 081/109] remove explicit default argument --- dist/std.min.scm | 2 +- dist/std.scm | 2 +- lib/bootstrap.scm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index 39358233..a250f80b 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -9,7 +9,7 @@ (define (single list) "(single list)\u000A\u000AFunction check if argument is list with single element" (and (pair? list) (not (cdr list)))) (define (iterator? x) "(iterator? x)\u000A\u000A Function check if value is JavaScript iterator object" (and (object? x) (procedure? (. x Symbol.iterator)))) (define-macro (.. expr) "(.. foo.bar.baz)\u000A\u000AMacro that gets value from nested object where argument is comma separated symbol" (if (not (symbol? expr)) expr (let ((parts (split "." (symbol->string expr)))) (if (single parts) expr (quasiquote (. (unquote (string->symbol (car parts))) (unquote-splicing (cdr parts)))))))) -(set-special! "#:" (quote gensym-interal) lips.specials.LITERAL) +(set-special! "#:" (quote gensym-interal)) (define (gensym-interal symbol) "(gensym-interal symbol)\u000A\u000AParser extension that create new quoted named gensym." (quasiquote (quote (unquote (gensym symbol))))) (define (plain-object? x) "(plain-object? x)\u000A\u000AFunction check if value is plain JavaScript object. Created using object macro." (and (== (--> (type x) (cmp "object")) 0) (eq? (. x (quote constructor)) Object))) (define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o)\u000A\u000AFunction test if argumnet is JavaScript typed array (Scheme byte vector)." (instanceof TypedArray o)))) diff --git a/dist/std.scm b/dist/std.scm index c0676cee..d2ea9359 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -175,7 +175,7 @@ `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) ;; ----------------------------------------------------------------------------- -(set-special! "#:" 'gensym-interal lips.specials.LITERAL) +(set-special! "#:" 'gensym-interal) ;; ----------------------------------------------------------------------------- (define (gensym-interal symbol) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 8b1027ac..dfdddc42 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -175,7 +175,7 @@ `(. ,(string->symbol (car parts)) ,@(cdr parts)))))) ;; ----------------------------------------------------------------------------- -(set-special! "#:" 'gensym-interal lips.specials.LITERAL) +(set-special! "#:" 'gensym-interal) ;; ----------------------------------------------------------------------------- (define (gensym-interal symbol) From ececeab957184fda051c9c188801452341a32448 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 5 Mar 2021 19:35:56 +0100 Subject: [PATCH 082/109] add typechecking to utf8 string functions --- dist/std.min.scm | 4 ++-- dist/std.scm | 2 ++ lib/R7RS.scm | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index a250f80b..cabcf7c4 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -304,8 +304,8 @@ (define (bytevector-append v1 . rest) "(bytevector-append v1 ...)\u000A\u000ACreate new bytevector u8vector that is created from joining each argument." (typecheck "bytevector-append" v1 "uint8array" 1) (map (lambda (arg) (typecheck "bytevector-append" arg "uint8array")) rest) (if (null? rest) v1 (new Uint8Array (apply vector-append (Array.from v1) (map Array.from rest))))) (define (bytevector-copy v . rest) "(bytevector-copy v)\u000A(bytevector-copy v start)\u000A(bytevector-copy v start end)\u000A\u000AFunction and return new vector from start to end. If no start and end is provided\u000Awhole vector is copied and returned." (if (null? rest) (new Uint8Array v) (let ((start (car rest))) (if (null? (cdr rest)) (v.slice start) (v.slice start (cadr rest)))))) (define (bytevector-copy! to at from . rest) "(bytevector-copy! to at from)\u000A(bytevector-copy! to at from start)\u000A(bytevector-copy! to at from start end)\u000A\u000ACopies the bytes of bytevector from between start and end to bytevector to,\u000Astarting at at." (typecheck "bytevector-copy!" to "uint8array") (typecheck "bytevector-copy!" from "uint8array") (cond ((< at 0) (throw (new Error "bytevector-copy! `at` need to be positive"))) ((> at (bytevector-length to)) (throw (new Error "bytevector-copy! `at` need to be less then byte vector length")))) (let* ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (- (bytevector-length from) start) (cadr rest)))) (let ((i at) (j start)) (while (and (< i (bytevector-length to)) (< i (bytevector-length from)) (< j (+ start end))) (bytevector-u8-set! to i (bytevector-u8-ref from j)) (set! i (+ i 1)) (set! j (+ j 1)))))) -(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) "(string->utf8 string)\u000A(string->utf8 string start)\u000A(string->utf8 string start end)\u000A\u000AFunction converts string into u8 bytevector using utf8 encoding.\u000AThe start and end is the range of the input string for the conversion." (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end))))))) -(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector)\u000A(utf8->string u8vector start)\u000A(utf8->string u8vector start end)\u000A\u000AFunction converts u8 bytevector into string using utf8 encoding.\u000AThe start and end is the range of the input byte vector for the conversion." (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end))))))) +(define string->utf8 (let ((encoder (new TextEncoder "utf-8"))) (lambda (string . rest) "(string->utf8 string)\u000A(string->utf8 string start)\u000A(string->utf8 string start end)\u000A\u000AFunction converts string into u8 bytevector using utf8 encoding.\u000AThe start and end is the range of the input string for the conversion." (typecheck "string->utf8" string "string") (if (null? rest) (encoder.encode string) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (encoder.encode (substring string start end))))))) +(define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector)\u000A(utf8->string u8vector start)\u000A(utf8->string u8vector start end)\u000A\u000AFunction converts u8 bytevector into string using utf8 encoding.\u000AThe start and end is the range of the input byte vector for the conversion." (typecheck "utf8->string" v "uint8array") (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end))))))) (define (open-input-string string) "(open-input-string string)\u000A\u000AFunction create new string port as input that can be used to\u000Aread S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment))) (define (open-output-string) "(open-output-string)\u000A\u000AFunction create new output port that can used to write string into\u000Aand after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr)) (define (get-output-string port) "(get-output-string port)\u000A\u000AFunction get full string from string port. If nothing was wrote\u000Ato given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString))) diff --git a/dist/std.scm b/dist/std.scm index d2ea9359..c1f2b9c1 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3459,6 +3459,7 @@ Function converts string into u8 bytevector using utf8 encoding. The start and end is the range of the input string for the conversion." + (typecheck "string->utf8" string "string") (if (null? rest) (encoder.encode string) (let* ((start (car rest)) @@ -3476,6 +3477,7 @@ Function converts u8 bytevector into string using utf8 encoding. The start and end is the range of the input byte vector for the conversion." + (typecheck "utf8->string" v "uint8array") (if (null? rest) (decoder.decode v) (let* ((start (car rest)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 50de6d13..799e4391 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -545,6 +545,7 @@ Function converts string into u8 bytevector using utf8 encoding. The start and end is the range of the input string for the conversion." + (typecheck "string->utf8" string "string") (if (null? rest) (encoder.encode string) (let* ((start (car rest)) @@ -562,6 +563,7 @@ Function converts u8 bytevector into string using utf8 encoding. The start and end is the range of the input byte vector for the conversion." + (typecheck "utf8->string" v "uint8array") (if (null? rest) (decoder.decode v) (let* ((start (car rest)) From 35854d7336080ff858981e38fa2be17015794720 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 5 Mar 2021 20:16:35 +0100 Subject: [PATCH 083/109] binary output port #132 --- README.md | 2 +- dist/lips.js | 77 +++++++++++++++++++++++++++++++++++++++--------- dist/lips.min.js | 4 +-- dist/std.min.scm | 7 ++++- dist/std.scm | 63 ++++++++++++++++++++++++++++++++++++++- lib/R7RS.scm | 63 ++++++++++++++++++++++++++++++++++++++- src/lips.js | 51 ++++++++++++++++++++++++++------ tests/ports.scm | 12 ++++++++ 8 files changed, 250 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 4ca1556e..334b5c54 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&b79b4fcc0c53bf8e6e46e2278500316693bd0ed3)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&ececeab957184fda051c9c188801452341a32448)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&f023d70c9b69774030a250f75064ef33)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index b1d73f5f..6ff7dc2f 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 11:45:43 +0000 + * build: Fri, 05 Mar 2021 19:10:37 +0000 */ (function () { 'use strict'; @@ -8918,7 +8918,7 @@ typecheck('OutputStringPort', toString, 'function'); read_only(this, '__type__', text_port); - this._buffer = []; + read_only(this, '__buffer__', []); this.write = function (x) { if (!LString.isString(x)) { @@ -8927,23 +8927,23 @@ x = x.valueOf(); } - _this8._buffer.push(x); + _this8.__buffer__.push(x); }; } OutputStringPort.prototype = Object.create(OutputPort.prototype); + OutputStringPort.prototype.constructor = OutputStringPort; OutputStringPort.prototype.toString = function () { return '#<output-port (string)>'; }; - OutputStringPort.prototype.getString = function () { - return this._buffer.map(function (x) { + OutputStringPort.prototype.valueOf = function () { + return this.__buffer__.map(function (x) { return x.valueOf(); }).join(''); - }; + }; // ------------------------------------------------------------------------- - OutputStringPort.prototype.constructor = OutputStringPort; // ------------------------------------------------------------------------- function OutputFilePort(filename, fd) { var _this9 = this; @@ -8953,8 +8953,10 @@ } typecheck('OutputFilePort', filename, 'string'); - this._filename = filename; - this._fd = fd.valueOf(); + read_only(this, '__filename__', filename); + read_only(this, '_fd', fd.valueOf(), { + hidden: true + }); read_only(this, '__type__', text_port); this.write = function (x) { @@ -8989,7 +8991,9 @@ if (err) { reject(err); } else { - _this10._fd = null; + read_only(_this10, '_fd', null, { + hidden: true + }); OutputPort.prototype.close.call(_this10); resolve(); } @@ -8998,7 +9002,7 @@ }; OutputFilePort.prototype.toString = function () { - return "#<output-port ".concat(this._filename, ">"); + return "#<output-port ".concat(this.__filename__, ">"); }; // ------------------------------------------------------------------------- @@ -9134,6 +9138,50 @@ }; // ------------------------------------------------------------------------- + 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 + }); + Object.defineProperty(this, '__buffer__', { + enumerable: true, + get: function get() { + return Uint8Array.from(this._buffer); + } + }); + } + + OutputByteVectorPort.prototype = Object.create(OutputPort.prototype); + OutputByteVectorPort.prototype.constructor = OutputByteVectorPort; + + OutputByteVectorPort.prototype.write_u8 = function (_byte2) { + var name = 'OutputByteVectorPort::write_u8'; + typecheck(name, _byte2, 'number'); + + this._buffer.push(_byte2.valueOf()); + }; + + OutputByteVectorPort.prototype.write_u8_vector = function (vector) { + var _this$_buffer; + + typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); + + (_this$_buffer = this._buffer).push.apply(_this$_buffer, toConsumableArray(Array.from(vector))); + }; + + OutputByteVectorPort.prototype.toString = function () { + return '#<output-port (bytevector)>'; + }; + + OutputByteVectorPort.prototype.valueOf = function () { + return this.__buffer__; + }; // ------------------------------------------------------------------------- + + function InputFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || typeof this === 'undefined') { return new InputFilePort(content, filename); @@ -13502,10 +13550,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 04 Mar 2021 11:45:43 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 05 Mar 2021 19:10:37 +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('Thu, 04 Mar 2021 11:45:43 +0000').valueOf(); + var date = LString('Fri, 05 Mar 2021 19:10:37 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13545,7 +13593,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 04 Mar 2021 11:45:43 +0000', + date: 'Fri, 05 Mar 2021 19:10:37 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), @@ -13572,6 +13620,7 @@ InputStringPort: InputStringPort, OutputStringPort: OutputStringPort, InputByteVectorPort: InputByteVectorPort, + OutputByteVectorPort: OutputByteVectorPort, InputBinaryFilePort: InputBinaryFilePort, Formatter: Formatter, Parser: Parser, diff --git a/dist/lips.min.js b/dist/lips.min.js index b8fee5f5..2b074c27 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 04 Mar 2021 11:45:43 +0000 + * build: Fri, 05 Mar 2021 19:10:37 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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);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.toString=function(){return"#<output-port (string)>"};OutputStringPort.prototype.getString=function(){return this._buffer.map(function(e){return e.valueOf()}).join("")};OutputStringPort.prototype.constructor=OutputStringPort;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");this._filename=e;this._fd=r.valueOf();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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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{n._fd=null;OutputPort.prototype.close.call(n);r()}})})};OutputFilePort.prototype.toString=function(){return"#<output-port ".concat(this._filename,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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 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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Thu, 04 Mar 2021 11:45:43 +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,") <https://lips.js.org>\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:"Thu, 04 Mar 2021 11:45:43 +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,InputBinaryFilePort:InputBinaryFilePort,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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});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.write_u8=function(e){var r="OutputByteVectorPort::write_u8";typecheck(r,e,"number");this._buffer.push(e.valueOf())};OutputByteVectorPort.prototype.write_u8_vector=function(e){var r;typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))};OutputByteVectorPort.prototype.toString=function(){return"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Fri, 05 Mar 2021 19:10:37 +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,") <https://lips.js.org>\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:"Fri, 05 Mar 2021 19:10:37 +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,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/dist/std.min.scm b/dist/std.min.scm index cabcf7c4..ddad05ee 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -308,7 +308,9 @@ (define utf8->string (let ((decoder (new TextDecoder "utf-8"))) (lambda (v . rest) "(utf8->string u8vector)\u000A(utf8->string u8vector start)\u000A(utf8->string u8vector start end)\u000A\u000AFunction converts u8 bytevector into string using utf8 encoding.\u000AThe start and end is the range of the input byte vector for the conversion." (typecheck "utf8->string" v "uint8array") (if (null? rest) (decoder.decode v) (let* ((start (car rest)) (len (--> (Array.from string) (quote length))) (end (if (null? (cdr rest)) len (cadr rest)))) (decoder.decode (v.slice start end))))))) (define (open-input-string string) "(open-input-string string)\u000A\u000AFunction create new string port as input that can be used to\u000Aread S-exressions from this port using `read` function." (typecheck "open-input-string" string "string") (new lips.InputStringPort string (interaction-environment))) (define (open-output-string) "(open-output-string)\u000A\u000AFunction create new output port that can used to write string into\u000Aand after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr)) -(define (get-output-string port) "(get-output-string port)\u000A\u000AFunction get full string from string port. If nothing was wrote\u000Ato given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.getString))) +(define (open-output-bytevector) "(open-output-bytevector)\u000A\u000ACreate new output port that can be used to write binary data.\u000AAfter done with the data the output buffer can be obtained by calling\u000A`get-output-bytevector` function." (new lips.OutputByteVectorPort)) +(define (get-output-bytevector port) "(get-output-string port)\u000A\u000AFunction get full string from string port. If nothing was wrote\u000Ato given port it will return empty string." (if (not (instanceof lips.OutputByteVectorPort port)) (throw (new Error (string-append "get-output-bytevector: expecting output-bytevector-port get " (type port)))) (port.valueOf))) +(define (get-output-string port) "(get-output-string port)\u000A\u000AFunction get full string from string port. If nothing was wrote\u000Ato given port it will return empty string." (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) (port.valueOf))) (define (open-input-bytevector bytevector) "(open-input-bytevector bytevector)\u000A\u000ACreate new input binary port with given bytevector" (typecheck "open-input-bytevector" bytevector "uint8array") (new lips.InputByteVectorPort bytevector)) (define (open-binary-input-file filename) "(open-binary-input-file filename)\u000A\u000AFunction return new Input Binary Port with given filename. In Browser\u000Auser need to provide global fs variable that is instance of FS interface." (let ((u8vector (buffer->u8vector (%read-binary-file filename)))) (new lips.InputBinaryFilePort u8vector filename))) (define (binary-port? port) "(binary-port? port)\u000A\u000AFunction test if argument is binary port." (and (port? port) (eq? port.__type__ (Symbol.for "binary")))) @@ -318,6 +320,9 @@ (%define-binary-input-lambda read-u8 "(read-u8)\u000A(read-u8 port)\u000A\u000ARead next byte from input-binary port. If there are no more bytes\u000Ait return eof object." (lambda (port) (port.read_u8))) (%define-binary-input-lambda u8-ready? "(u8-ready?)\u000A(u8-ready? port)\u000A\u000AReturns #t if a byte is ready on the binary input port and returns #f otherwise.\u000AIf u8-ready? returns #t then the next read-u8 operation on the given port is\u000Aguaranteed not to hang. If the port is at end of file then u8-ready? returns #t." (lambda (port) (port.u8_ready))) (define (read-bytevector k . rest) "(read-bytevector k)\u000A(read-bytevector k port)\u000A\u000ARead next n bytes from input-binary port. If there are no more bytes\u000Ait returns eof object. If there are less then n bytes in port it\u000Areturn the only bytes that are available" (let ((port (if (null? rest) (current-input-port) (car rest)))) (typecheck "read-bytevector" port "input-port") (if (not (binary-port? port)) (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k)))) +(define-macro (%define-binary-output-lambda name type docstring fn) (let ((port (gensym (quote port))) (data (gensym (quote data))) (name-str (symbol->string name))) (quasiquote (define ((unquote name) (unquote data) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-output-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "output-port") (typecheck (unquote name-str) (unquote data) (unquote type)) (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port. Binary port required."))) ((unquote fn) (unquote data) (unquote port)))))))) +(%define-binary-output-lambda write-u8 "number" "(write-u8 byte)\u000A(write-u8 byte port)\u000A\u000AWrite byte into binary output port." (lambda (data port) (port.write_u8 data))) +(%define-binary-output-lambda write-bytevector "uint8array" "(write-bytevector bytevector)\u000A(write-bytevector bytevector port)\u000A\u000AWrite byte vector into binary output port." (lambda (data port) (port.write_u8_vector data))) (define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename)\u000A\u000AFunction delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename))))))) (define (call-with-port port proc) "(call-with-port port proc)\u000A\u000AProc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close))))) (define (close-port port) "(close-port port)\u000A\u000AClose input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close)) diff --git a/dist/std.scm b/dist/std.scm index c1f2b9c1..7fea776a 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3502,6 +3502,27 @@ and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr)) +;; ----------------------------------------------------------------------------- +(define (open-output-bytevector) + "(open-output-bytevector) + + Create new output port that can be used to write binary data. + After done with the data the output buffer can be obtained by calling + `get-output-bytevector` function." + (new lips.OutputByteVectorPort)) + +;; ----------------------------------------------------------------------------- +(define (get-output-bytevector port) + "(get-output-string port) + + Function get full string from string port. If nothing was wrote + to given port it will return empty string." + (if (not (instanceof lips.OutputByteVectorPort port)) + (throw (new Error (string-append + "get-output-bytevector: expecting output-bytevector-port get " + (type port)))) + (port.valueOf))) + ;; ----------------------------------------------------------------------------- (define (get-output-string port) "(get-output-string port) @@ -3511,7 +3532,7 @@ (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) - (port.getString))) + (port.valueOf))) ;; ----------------------------------------------------------------------------- (define (open-input-bytevector bytevector) @@ -3609,6 +3630,46 @@ (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k)))) +;; ----------------------------------------------------------------------------- +(define-macro (%define-binary-output-lambda name type docstring fn) + (let ((port (gensym 'port)) + (data (gensym 'data)) + (name-str (symbol->string name))) + `(define (,name ,data . rest) + ,docstring + (let ((,port (if (null? rest) + (current-output-port) + (car rest)))) + (typecheck ,name-str ,port "output-port") + (typecheck ,name-str ,data ,type) + (if (not (binary-port? ,port)) + (throw (new Error (string-append ,name-str + " invalid port. Binary port required."))) + (,fn ,data ,port)))))) + +;; ----------------------------------------------------------------------------- +(%define-binary-output-lambda + write-u8 + "number" + "(write-u8 byte) + (write-u8 byte port) + + Write byte into binary output port." + (lambda (data port) + (port.write_u8 data))) + +;; ----------------------------------------------------------------------------- +(%define-binary-output-lambda + write-bytevector + "uint8array" + "(write-bytevector bytevector) + (write-bytevector bytevector port) + + Write byte vector into binary output port." + (lambda (data port) + (port.write_u8_vector data))) + + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 799e4391..de956060 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -588,6 +588,27 @@ and after finish get the whole string using `get-output-string`." (new lips.OutputStringPort repr)) +;; ----------------------------------------------------------------------------- +(define (open-output-bytevector) + "(open-output-bytevector) + + Create new output port that can be used to write binary data. + After done with the data the output buffer can be obtained by calling + `get-output-bytevector` function." + (new lips.OutputByteVectorPort)) + +;; ----------------------------------------------------------------------------- +(define (get-output-bytevector port) + "(get-output-string port) + + Function get full string from string port. If nothing was wrote + to given port it will return empty string." + (if (not (instanceof lips.OutputByteVectorPort port)) + (throw (new Error (string-append + "get-output-bytevector: expecting output-bytevector-port get " + (type port)))) + (port.valueOf))) + ;; ----------------------------------------------------------------------------- (define (get-output-string port) "(get-output-string port) @@ -597,7 +618,7 @@ (if (not (instanceof lips.OutputStringPort port)) (throw (new Error (string-append "get-output-string: expecting output-string-port get " (type port)))) - (port.getString))) + (port.valueOf))) ;; ----------------------------------------------------------------------------- (define (open-input-bytevector bytevector) @@ -695,6 +716,46 @@ (throw (new Error "read-bytevector: invalid port")) (port.read_u8_vector k)))) +;; ----------------------------------------------------------------------------- +(define-macro (%define-binary-output-lambda name type docstring fn) + (let ((port (gensym 'port)) + (data (gensym 'data)) + (name-str (symbol->string name))) + `(define (,name ,data . rest) + ,docstring + (let ((,port (if (null? rest) + (current-output-port) + (car rest)))) + (typecheck ,name-str ,port "output-port") + (typecheck ,name-str ,data ,type) + (if (not (binary-port? ,port)) + (throw (new Error (string-append ,name-str + " invalid port. Binary port required."))) + (,fn ,data ,port)))))) + +;; ----------------------------------------------------------------------------- +(%define-binary-output-lambda + write-u8 + "number" + "(write-u8 byte) + (write-u8 byte port) + + Write byte into binary output port." + (lambda (data port) + (port.write_u8 data))) + +;; ----------------------------------------------------------------------------- +(%define-binary-output-lambda + write-bytevector + "uint8array" + "(write-bytevector bytevector) + (write-bytevector bytevector port) + + Write byte vector into binary output port." + (lambda (data port) + (port.write_u8_vector data))) + + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/src/lips.js b/src/lips.js index 302d3ef6..2e955e3b 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5648,24 +5648,24 @@ } typecheck('OutputStringPort', toString, 'function'); read_only(this, '__type__', text_port); - this._buffer = []; + read_only(this, '__buffer__', []); this.write = (x) => { if (!LString.isString(x)) { x = toString(x); } else { x = x.valueOf(); } - this._buffer.push(x); + this.__buffer__.push(x); }; } OutputStringPort.prototype = Object.create(OutputPort.prototype); + OutputStringPort.prototype.constructor = OutputStringPort; OutputStringPort.prototype.toString = function() { return '#<output-port (string)>'; }; - OutputStringPort.prototype.getString = function() { - return this._buffer.map(x => x.valueOf()).join(''); + OutputStringPort.prototype.valueOf = function() { + return this.__buffer__.map(x => x.valueOf()).join(''); }; - OutputStringPort.prototype.constructor = OutputStringPort; // ------------------------------------------------------------------------- function OutputFilePort(filename, fd) { if (typeof this !== 'undefined' && !(this instanceof OutputFilePort) || @@ -5673,8 +5673,8 @@ return new OutputFilePort(filename, fd); } typecheck('OutputFilePort', filename, 'string'); - this._filename = filename; - this._fd = fd.valueOf(); + read_only(this, '__filename__', filename); + read_only(this, '_fd', fd.valueOf(), { hidden: true }); read_only(this, '__type__', text_port); this.write = (x) => { if (!LString.isString(x)) { @@ -5700,7 +5700,7 @@ if (err) { reject(err); } else { - this._fd = null; + read_only(this, '_fd', null, { hidden: true }); OutputPort.prototype.close.call(this); resolve(); } @@ -5708,7 +5708,7 @@ }); }; OutputFilePort.prototype.toString = function() { - return `#<output-port ${this._filename}>`; + return `#<output-port ${this.__filename__}>`; }; // ------------------------------------------------------------------------- function InputStringPort(string, env) { @@ -5814,6 +5814,38 @@ return this.__vector__.slice(this.__index__, len); }; // ------------------------------------------------------------------------- + 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 }); + Object.defineProperty(this, '__buffer__', { + enumerable: true, + get: function() { + return Uint8Array.from(this._buffer); + } + }); + } + OutputByteVectorPort.prototype = Object.create(OutputPort.prototype); + OutputByteVectorPort.prototype.constructor = OutputByteVectorPort; + OutputByteVectorPort.prototype.write_u8 = function(byte) { + var name = 'OutputByteVectorPort::write_u8'; + typecheck(name, byte, 'number'); + this._buffer.push(byte.valueOf()); + }; + OutputByteVectorPort.prototype.write_u8_vector = function(vector) { + typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); + this._buffer.push(...Array.from(vector)); + }; + OutputByteVectorPort.prototype.toString = function() { + return '#<output-port (bytevector)>'; + }; + OutputByteVectorPort.prototype.valueOf = function() { + return this.__buffer__; + }; + // ------------------------------------------------------------------------- function InputFilePort(content, filename) { if (typeof this !== 'undefined' && !(this instanceof InputFilePort) || typeof this === 'undefined') { @@ -9621,6 +9653,7 @@ You can also use (help name) to display help for specic function or macro and InputStringPort, OutputStringPort, InputByteVectorPort, + OutputByteVectorPort, InputBinaryFilePort, Formatter, diff --git a/tests/ports.scm b/tests/ports.scm index f6d2104e..ae6088c9 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -253,3 +253,15 @@ (let ((p (open-binary-input-file "./tests/stubs/test.txt"))) (t.is (utf8->string (read-bytevector 10 p)) "Hello this")))) + +(test "ports: binary output port" + (lambda (t) + (let ((port (open-output-bytevector)) + (v (string->utf8 "hello"))) + (for-each (lambda (byte) + (write-u8 byte port)) + (u8vector->list v)) + (write-u8 (char->integer #\space) port) + (write-bytevector (string->utf8 "world") port) + (let ((u8 (get-output-bytevector port))) + (t.is (utf8->string u8) "hello world"))))) From 164fb31e5d946c7f1a40473edd00c9049e2b7ace Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 5 Mar 2021 20:17:42 +0100 Subject: [PATCH 084/109] fix lint error #132 --- README.md | 4 ++-- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 334b5c54..c2834577 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&ececeab957184fda051c9c188801452341a32448)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&f023d70c9b69774030a250f75064ef33)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&35854d7336080ff858981e38fa2be17015794720)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&73c1bc9d6ea5002affa17aaf89ac473d)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 6ff7dc2f..7266bd55 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 05 Mar 2021 19:10:37 +0000 + * build: Fri, 05 Mar 2021 19:17:29 +0000 */ (function () { 'use strict'; @@ -1234,7 +1234,7 @@ * TODO: consider using exec in env.eval or use different maybe_async code */ - /* global define, jQuery, BigInt, Map, Set, Symbol, importScripts */ + /* global define, jQuery, BigInt, Map, Set, Symbol, importScripts, Uint8Array */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. @@ -13550,10 +13550,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 05 Mar 2021 19:10:37 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Fri, 05 Mar 2021 19:17:29 +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('Fri, 05 Mar 2021 19:10:37 +0000').valueOf(); + var date = LString('Fri, 05 Mar 2021 19:17:29 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13593,7 +13593,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 05 Mar 2021 19:10:37 +0000', + date: 'Fri, 05 Mar 2021 19:17:29 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 2b074c27..81ab1e82 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 05 Mar 2021 19:10:37 +0000 + * build: Fri, 05 Mar 2021 19:17:29 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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});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.write_u8=function(e){var r="OutputByteVectorPort::write_u8";typecheck(r,e,"number");this._buffer.push(e.valueOf())};OutputByteVectorPort.prototype.write_u8_vector=function(e){var r;typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))};OutputByteVectorPort.prototype.toString=function(){return"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Fri, 05 Mar 2021 19:10:37 +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,") <https://lips.js.org>\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:"Fri, 05 Mar 2021 19:10:37 +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,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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});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.write_u8=function(e){var r="OutputByteVectorPort::write_u8";typecheck(r,e,"number");this._buffer.push(e.valueOf())};OutputByteVectorPort.prototype.write_u8_vector=function(e){var r;typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))};OutputByteVectorPort.prototype.toString=function(){return"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Fri, 05 Mar 2021 19:17:29 +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,") <https://lips.js.org>\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:"Fri, 05 Mar 2021 19:17:29 +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,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/src/lips.js b/src/lips.js index 2e955e3b..28e419d5 100644 --- a/src/lips.js +++ b/src/lips.js @@ -39,7 +39,7 @@ /* * TODO: consider using exec in env.eval or use different maybe_async code */ -/* global define, jQuery, BigInt, Map, Set, Symbol, importScripts */ +/* global define, jQuery, BigInt, Map, Set, Symbol, importScripts, Uint8Array */ (function(root, factory) { if (typeof define === 'function' && define.amd) { From a85d1640eafb254a733133d657cd8498b6cd2adb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 6 Mar 2021 15:44:21 +0100 Subject: [PATCH 085/109] binary output file port + refactoring #132 --- README.md | 4 +- dist/lips.js | 165 +++++++++++++++++++++++++++++++++++----------- dist/lips.min.js | 4 +- dist/std.min.scm | 8 ++- dist/std.scm | 62 +++++++++++------ lib/R5RS.scm | 14 ++-- lib/R7RS.scm | 24 +++++-- lib/bootstrap.scm | 24 ++++++- src/lips.js | 91 +++++++++++++++++++++---- tests/ports.scm | 55 ++++++++++++---- 10 files changed, 343 insertions(+), 108 deletions(-) diff --git a/README.md b/README.md index c2834577..102c817f 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&35854d7336080ff858981e38fa2be17015794720)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&73c1bc9d6ea5002affa17aaf89ac473d)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&164fb31e5d946c7f1a40473edd00c9049e2b7ace)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&05f17e62b8878f9ec268a2f2c28fc2a9)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 7266bd55..8a4e1560 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 05 Mar 2021 19:17:29 +0000 + * build: Sat, 06 Mar 2021 11:33:45 +0000 */ (function () { 'use strict'; @@ -8966,28 +8966,34 @@ x = x.valueOf(); } - _this9.fs('write')(_this9._fd, x, function () {}); + _this9.fs().write(_this9._fd, x, function (err) { + if (err) { + throw err; + } + }); }; } OutputFilePort.prototype = Object.create(OutputPort.prototype); OutputFilePort.prototype.constructor = OutputFilePort; - OutputFilePort.prototype.fs = function (name) { - var fs = user_env.get('**internal-env**').get('fs'); - - if (!fs) { - throw new Error("".concat(name, ": fs is not defined")); + OutputFilePort.prototype.fs = function () { + if (!this._fs) { + this._fs = this.internal('fs'); } - return fs[name]; + return this._fs; + }; + + OutputFilePort.prototype.internal = function (name) { + return user_env.get('**internal-env**').get(name); }; OutputFilePort.prototype.close = function () { var _this10 = this; return new Promise(function (resolve, reject) { - _this10.fs('close')(_this10._fd, function (err) { + _this10.fs().close(_this10._fd, function (err) { if (err) { reject(err); } else { @@ -9147,6 +9153,19 @@ read_only(this, '_buffer', [], { hidden: true }); + + this.write = function (x) { + typecheck('write', x, ['number', 'uint8array']); + + if (LNumber.isNumber(x)) { + this._buffer.push(x.valueOf()); + } else { + var _this$_buffer; + + (_this$_buffer = this._buffer).push.apply(_this$_buffer, toConsumableArray(Array.from(x))); + } + }; + Object.defineProperty(this, '__buffer__', { enumerable: true, get: function get() { @@ -9158,19 +9177,27 @@ OutputByteVectorPort.prototype = Object.create(OutputPort.prototype); OutputByteVectorPort.prototype.constructor = OutputByteVectorPort; - OutputByteVectorPort.prototype.write_u8 = function (_byte2) { - var name = 'OutputByteVectorPort::write_u8'; - typecheck(name, _byte2, 'number'); + OutputByteVectorPort.prototype.close = function () { + OutputPort.prototype.close.call(this); + read_only(this, '_buffer', null, { + hidden: true + }); + }; - this._buffer.push(_byte2.valueOf()); + OutputByteVectorPort.prototype._close_guard = function () { + if (this._closed) { + throw new Error('output-port: binary port is closed'); + } }; - OutputByteVectorPort.prototype.write_u8_vector = function (vector) { - var _this$_buffer; + OutputByteVectorPort.prototype.write_u8 = function (_byte2) { + typecheck('OutputByteVectorPort::write_u8', _byte2, 'number'); + this.write(_byte2); + }; + OutputByteVectorPort.prototype.write_u8_vector = function (vector) { typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); - - (_this$_buffer = this._buffer).push.apply(_this$_buffer, toConsumableArray(Array.from(vector))); + this.write(vector); }; OutputByteVectorPort.prototype.toString = function () { @@ -9218,6 +9245,65 @@ }; // ------------------------------------------------------------------------- + function OutputBinaryFilePort(filename, fd) { + if (typeof this !== 'undefined' && !(this instanceof OutputBinaryFilePort) || typeof this === 'undefined') { + return new OutputBinaryFilePort(filename, fd); + } + + typecheck('OutputBinaryFilePort', filename, 'string'); + read_only(this, '__filename__', filename); + read_only(this, '_fd', fd.valueOf(), { + hidden: true + }); + read_only(this, '__type__', binary_port); + var fs, Buffer; + + this.write = function (x) { + var _this13 = this; + + typecheck('write', x, ['number', 'uint8array']); + var buffer; + + if (!fs) { + fs = this.internal('fs'); + } + + if (!Buffer) { + Buffer = this.internal('Buffer'); + } + + if (LNumber.isNumber(x)) { + buffer = Buffer.from([x.valueOf()]); + } else { + buffer = Buffer.from(Array.from(x)); + } + + return new Promise(function (resolve, reject) { + fs.write(_this13._fd, buffer, function (err) { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); + }; + } + + OutputBinaryFilePort.prototype = Object.create(OutputFilePort.prototype); + OutputBinaryFilePort.prototype.constructor = OutputBinaryFilePort; + + OutputBinaryFilePort.prototype.write_u8 = function (_byte3) { + typecheck('OutputByteVectorPort::write_u8', _byte3, 'number'); + this.write(_byte3); + }; + + OutputBinaryFilePort.prototype.write_u8_vector = function (vector) { + typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); + this.write(vector); + }; // ------------------------------------------------------------------------- + + var binary_port = Symbol["for"]('binary'); var text_port = Symbol["for"]('text'); var eof = new EOF(); @@ -9455,13 +9541,13 @@ Environment.prototype.clone = function () { - var _this13 = this; + var _this14 = this; // duplicate refs var env = {}; // TODO: duplicated Symbols Object.keys(this.__env__).forEach(function (key) { - env[key] = _this13.__env__[key]; + env[key] = _this14.__env__[key]; }); return new Environment(env, this.__parent__, this.__name__); }; // ------------------------------------------------------------------------- @@ -9618,7 +9704,7 @@ Environment.prototype.constant = function (name, value) { - var _this14 = this; + var _this15 = this; if (this.__env__.hasOwnProperty(name)) { throw new Error("Environment::constant: ".concat(name, " already exists")); @@ -9627,7 +9713,7 @@ if (arguments.length === 1 && is_plain_object(arguments[0])) { var obj = arguments[0]; Object.keys(obj).forEach(function (key) { - _this14.constant(name, obj[key]); + _this15.constant(name, obj[key]); }); } else { Object.defineProperty(this.__env__, name, { @@ -10087,7 +10173,7 @@ }, "(cdr pair)\n\n Function returns cdr (tail) of the list/pair."), // ------------------------------------------------------------------ 'set!': doc(new Macro('set!', function (code) { - var _this15 = this; + var _this16 = this; var _ref29 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, dynamic_scope = _ref29.dynamic_scope, @@ -10162,7 +10248,7 @@ var key = parts.pop(); var name = parts.join('.'); - var obj = _this15.get(name, { + var obj = _this16.get(name, { throwError: false }); @@ -10667,7 +10753,7 @@ }, "(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."), // ------------------------------------------------------------------ 'eval': doc('eval', function (code, env) { - var _this16 = this; + var _this17 = this; env = env || this; return evaluate(code, { @@ -10675,13 +10761,13 @@ //dynamic_scope: this, error: function error(e) { var error = global_env.get('error'); - error.call(_this16, e.message); + error.call(_this17, e.message); if (e.code) { var stack = e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); }).join('\n'); - error.call(_this16, stack); + error.call(_this17, stack); } } }); @@ -11743,7 +11829,7 @@ }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ 'try': doc(new Macro('try', function (code, _ref39) { - var _this17 = this; + var _this18 = this; var dynamic_scope = _ref39.dynamic_scope, _error = _ref39.error; @@ -11777,9 +11863,9 @@ } var args = { - env: _this17, + env: _this18, error: function error(e) { - var env = _this17.inherit('try'); + var env = _this18.inherit('try'); if (catch_clause) { env.set(catch_clause.cdr.car.car, e); @@ -11789,7 +11875,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this17; + args.dynamic_scope = _this18; } unpromise(evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { @@ -11802,7 +11888,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this17; + args.dynamic_scope = _this18; } var result = evaluate(code.car, args); @@ -11862,7 +11948,7 @@ }, "(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."), // ------------------------------------------------------------------ map: doc(function map(fn) { - var _this18 = this; + var _this19 = this; for (var _len29 = arguments.length, lists = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { lists[_key29 - 1] = arguments[_key29]; @@ -11873,7 +11959,7 @@ lists.forEach(function (arg, i) { typecheck('map', arg, ['pair', 'nil'], i + 1); // detect cycles - if (arg instanceof Pair && !is_list.call(_this18, arg)) { + if (arg instanceof Pair && !is_list.call(_this19, arg)) { throw new Error("map: argument ".concat(i + 1, " is not a list")); } }); @@ -11895,7 +11981,7 @@ var env = this.newFrame(fn, args); env.set('parent.frame', parent_frame); return unpromise(fn.call.apply(fn, [env].concat(toConsumableArray(args))), function (head) { - return unpromise(map.call.apply(map, [_this18, fn].concat(toConsumableArray(lists.map(function (l) { + return unpromise(map.call.apply(map, [_this19, fn].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))), function (rest) { return new Pair(head, rest); @@ -11991,7 +12077,7 @@ }, "(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."), // ------------------------------------------------------------------ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { - var _this19 = this; + var _this20 = this; for (var _len32 = arguments.length, lists = new Array(_len32 > 3 ? _len32 - 3 : 0), _key33 = 3; _key33 < _len32; _key33++) { lists[_key33 - 3] = arguments[_key33]; @@ -12011,7 +12097,7 @@ return unpromise(fn.apply(void 0, toConsumableArray(lists.map(function (l) { return l.car; })).concat([init])), function (value) { - return reduce.call.apply(reduce, [_this19, fn, value].concat(toConsumableArray(lists.map(function (l) { + return reduce.call.apply(reduce, [_this20, fn, value].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))); }); @@ -13550,10 +13636,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Fri, 05 Mar 2021 19:17:29 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 06 Mar 2021 11:33:45 +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('Fri, 05 Mar 2021 19:17:29 +0000').valueOf(); + var date = LString('Sat, 06 Mar 2021 11:33:45 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13593,7 +13679,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Fri, 05 Mar 2021 19:17:29 +0000', + date: 'Sat, 06 Mar 2021 11:33:45 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), @@ -13622,6 +13708,7 @@ InputByteVectorPort: InputByteVectorPort, OutputByteVectorPort: OutputByteVectorPort, InputBinaryFilePort: InputBinaryFilePort, + OutputBinaryFilePort: OutputBinaryFilePort, Formatter: Formatter, Parser: Parser, Lexer: Lexer, diff --git a/dist/lips.min.js b/dist/lips.min.js index 81ab1e82..88df27be 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Fri, 05 Mar 2021 19:17:29 +0000 + * build: Sat, 06 Mar 2021 11:33:45 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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(){})}}OutputFilePort.prototype=Object.create(OutputPort.prototype);OutputFilePort.prototype.constructor=OutputFilePort;OutputFilePort.prototype.fs=function(e){var r=user_env.get("**internal-env**").get("fs");if(!r){throw new Error("".concat(e,": fs is not defined"))}return r[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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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});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.write_u8=function(e){var r="OutputByteVectorPort::write_u8";typecheck(r,e,"number");this._buffer.push(e.valueOf())};OutputByteVectorPort.prototype.write_u8_vector=function(e){var r;typecheck("OutputByteVectorPort::write_u8_vector",e,"uint8array");(r=this._buffer).push.apply(r,toConsumableArray(Array.from(e)))};OutputByteVectorPort.prototype.toString=function(){return"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};var binary_port=Symbol["for"]("binary");var text_port=Symbol["for"]("text");var eof=new EOF;function EOF(){}EOF.prototype.toString=function(){return"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Fri, 05 Mar 2021 19:17:29 +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,") <https://lips.js.org>\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:"Fri, 05 Mar 2021 19:17:29 +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,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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 11:33:45 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 11:33:45 +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/dist/std.min.scm b/dist/std.min.scm index ddad05ee..69fd6c11 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -99,11 +99,12 @@ (define-macro (%not-implemented name) "(not-implemented name)\u000A\u000AReturns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ")\u000A\u000AThis function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented")))))))) (define-macro (%make-env name . names) "(%make-env name f1 f2 ...)\u000A\u000ACreate new Environment with given name and defined symbols in it from global env.\u000AIf given function name f1 f2 ... don't exists, it will define function that\u000Athrow exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name)))) (define Y (lambda (h) "(Y f)\u000A\u000A _ __ __ _ _ _ _ __ __ _ _ _\u000A / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\\u000A+ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + +\u000A| \\ / | \\ \\ | | |__ | | \\ / | |__ | | |\u000A| | | | / \\ | | __| | | | | | __| | | |\u000A| | | | / /\\ \\ | | | | | | | | | | | |\u000A+ |_| + /_/ \\_\\ + |_| + + |_| |_| + + +\u000A \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args))))))) -(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e)))))))))) (if (not (null? fs)) (--> lips.env (get (quote **internal-env**)) (set "fs" fs)))) +(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e))))))))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) (. (BrowserFS.BFSRequire "buffer") (quote Buffer)))))) (let ((internal (lips.env.get (quote **internal-env**)))) (if (not (null? Buffer)) (internal.set "Buffer" Buffer)) (if (not (null? fs)) (internal.set "fs" fs)))) (define (environment? obj) "(environment? obj)\u000A\u000AFunction check if object is LIPS environment." (instanceof lips.Environment obj)) (define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path)\u000A\u000ARead file from url or file system. If binary is false it will return\u000Astring that contain all the content. For HTTP requests, If binary\u000Ais false it will: when in browser return ArrayBuffer and in Node\u000Ait will return Buffer object. When reading from file system\u000Ain both cases it will return Buffer objects.\u000A\u000AThe code that use those function, in binary mode, need to check\u000Aif the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) (define %read-binary-file (curry %read-file #t)) (define %read-text-file (curry %read-file #f)) +(define (%fs-promisify-proc fn message) "(%fs-promisify-proc fn string)\u000A\u000AFunction return promisified version of fs function or throw exception\u000Aif fs is not available." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error (string-append message ": fs not defined"))) (promisify (. fs fn))))) (define (response->content binary res) "(response->text binary res)\u000A\u000AFunction read all text from Node.js HTTP response object. If binary argument is\u000Atrue it will return Buffer object that can be converted to u8vector.\u000A\u000A***Warrning:*** it may overflow the stack (part of Node) when converting\u000Awhole buffer to u8vector." (let ((result (vector))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" (lambda (chunk) (result.push (Buffer.from chunk "binary")))) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join ""))))))))) (define response->buffer (curry response->content #t)) (define response->text (curry response->content #f)) @@ -248,7 +249,7 @@ (define (with-input-from-file string thunk) "(with-input-from-file string thunk)\u000A\u000AProcedure open file and make it current-input-port then thunk is executed.\u000AAfter thunk is executed current-input-port is restored and file port\u000Ais closed." (let* ((port (open-input-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdin (internal-env.get "stdin"))) (internal-env.set "stdin" port) (try (thunk) (finally (internal-env.set "stdin" old-stdin) (close-input-port port))))) (define (with-output-to-file string thunk) (let* ((port (open-output-file string)) (env **interaction-environment**) (internal-env (env.get (quote **internal-env**))) (old-stdout (internal-env.get "stdout"))) (internal-env.set "stdout" port) (try (thunk) (finally (internal-env.set "stdout" old-stdout) (close-output-port port))))) (define (file-exists? filename) (new Promise (lambda (resolve) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))) -(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-output-file: fs not defined")) (begin (if (not (procedure? open)) (set! open (promisify fs.open))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w"))))))))) +(define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (if (not (procedure? open)) (set! open (%fs-promisify-proc (quote open) "open-output-file"))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w")))))) (define (scheme-report-environment version) "(scheme-report-environment version)\u000A\u000AFunction return new Environment object for given Scheme Spec version.\u000AOnly argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported")))))) (define-macro (%make-vector prefix type help) "(%make-vector prefix type help)\u000A\u000AMega helper macro that create list of functions for single byte vector\u000Abased on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...)\u000A\u000ACreate ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v)\u000A\u000Areturn length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a v1 v2 ...)\u000A\u000AAllocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x)\u000A\u000AFunction return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k)\u000A\u000AFunction set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote)))))))) (%make-vector u8 Uint8Array "usigned 8-bit integer vector") @@ -323,7 +324,8 @@ (define-macro (%define-binary-output-lambda name type docstring fn) (let ((port (gensym (quote port))) (data (gensym (quote data))) (name-str (symbol->string name))) (quasiquote (define ((unquote name) (unquote data) . rest) (unquote docstring) (let (((unquote port) (if (null? rest) (current-output-port) (car rest)))) (typecheck (unquote name-str) (unquote port) "output-port") (typecheck (unquote name-str) (unquote data) (unquote type)) (if (not (binary-port? (unquote port))) (throw (new Error (string-append (unquote name-str) " invalid port. Binary port required."))) ((unquote fn) (unquote data) (unquote port)))))))) (%define-binary-output-lambda write-u8 "number" "(write-u8 byte)\u000A(write-u8 byte port)\u000A\u000AWrite byte into binary output port." (lambda (data port) (port.write_u8 data))) (%define-binary-output-lambda write-bytevector "uint8array" "(write-bytevector bytevector)\u000A(write-bytevector bytevector port)\u000A\u000AWrite byte vector into binary output port." (lambda (data port) (port.write_u8_vector data))) -(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename)\u000A\u000AFunction delete the file of given name." (typecheck "delete-file" filename "string") (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "delete-file: fs not defined")) (begin (if (not (procedure? unlink)) (set! unlink (promisify fs.unlink))) (unlink filename))))))) +(define open-binary-output-file (let ((open)) (lambda (filename) "(open-binary-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (if (not (procedure? open)) (set! open (%fs-promisify-proc (quote open) "open-binary-output-file"))) (if (file-exists? filename) (throw (new Error "open-binary-output-file: file exists")) (lips.OutputBinaryFilePort filename (open filename "w")))))) +(define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename)\u000A\u000AFunction delete the file of given name." (typecheck "delete-file" filename "string") (if (not (procedure? unlink)) (set! unlink (%fs-promisify-proc (quote unlink) "delete-file"))) (unlink filename)))) (define (call-with-port port proc) "(call-with-port port proc)\u000A\u000AProc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close))))) (define (close-port port) "(close-port port)\u000A\u000AClose input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close)) (define (eof-object) "(eof-object)\u000A\u000AProcedure returns eof object that indicate end of the port" lips.eof) diff --git a/dist/std.scm b/dist/std.scm index 7fea776a..e6fd5a68 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1236,9 +1236,16 @@ (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) - (if (not (null? fs)) - (--> lips.env (get '**internal-env**) (set "fs" fs)))) + (reject e))))))))) + (Buffer (cond ((eq? self global) + self.Buffer) + ((not (null? self.BrowserFS)) + (. (BrowserFS.BFSRequire "buffer") 'Buffer))))) + (let ((internal (lips.env.get '**internal-env**))) + (if (not (null? Buffer)) + (internal.set "Buffer" Buffer)) + (if (not (null? fs)) + (internal.set "fs" fs)))) ;; ----------------------------------------------------------------------------- (define (environment? obj) @@ -1296,6 +1303,17 @@ (define %read-binary-file (curry %read-file true)) (define %read-text-file (curry %read-file false)) +;; ----------------------------------------------------------------------------- +(define (%fs-promisify-proc fn message) + "(%fs-promisify-proc fn string) + + Function return promisified version of fs function or throw exception + if fs is not available." + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error (string-append message ": fs not defined"))) + (promisify (. fs fn))))) + ;; ----------------------------------------------------------------------------- (define (response->content binary res) "(response->text binary res) @@ -2727,15 +2745,11 @@ Function open file and return port that can be used for writing. If file exists it will throw an Error." (typecheck "open-output-file" filename "string") - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "open-output-file: fs not defined")) - (begin - (if (not (procedure? open)) - (set! open (promisify fs.open))) - (if (file-exists? filename) - (throw (new Error "open-output-file: file exists")) - (lips.OutputFilePort filename (open filename "w"))))))))) + (if (not (procedure? open)) + (set! open (%fs-promisify-proc 'open "open-output-file"))) + (if (file-exists? filename) + (throw (new Error "open-output-file: file exists")) + (lips.OutputFilePort filename (open filename "w")))))) ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) @@ -3669,6 +3683,20 @@ (lambda (data port) (port.write_u8_vector data))) +;; ----------------------------------------------------------------------------- +(define open-binary-output-file + (let ((open)) + (lambda (filename) + "(open-binary-output-file filename) + + Function open file and return port that can be used for writing. If file + exists it will throw an Error." + (typecheck "open-output-file" filename "string") + (if (not (procedure? open)) + (set! open (%fs-promisify-proc 'open "open-binary-output-file"))) + (if (file-exists? filename) + (throw (new Error "open-binary-output-file: file exists")) + (lips.OutputBinaryFilePort filename (open filename "w")))))) ;; ----------------------------------------------------------------------------- (define delete-file @@ -3678,13 +3706,9 @@ Function delete the file of given name." (typecheck "delete-file" filename "string") - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "delete-file: fs not defined")) - (begin - (if (not (procedure? unlink)) - (set! unlink (promisify fs.unlink))) - (unlink filename))))))) + (if (not (procedure? unlink)) + (set! unlink (%fs-promisify-proc 'unlink "delete-file"))) + (unlink filename)))) ;; ----------------------------------------------------------------------------- (define (call-with-port port proc) diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 05941ac6..7cb2aab7 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -1364,15 +1364,11 @@ Function open file and return port that can be used for writing. If file exists it will throw an Error." (typecheck "open-output-file" filename "string") - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "open-output-file: fs not defined")) - (begin - (if (not (procedure? open)) - (set! open (promisify fs.open))) - (if (file-exists? filename) - (throw (new Error "open-output-file: file exists")) - (lips.OutputFilePort filename (open filename "w"))))))))) + (if (not (procedure? open)) + (set! open (%fs-promisify-proc 'open "open-output-file"))) + (if (file-exists? filename) + (throw (new Error "open-output-file: file exists")) + (lips.OutputFilePort filename (open filename "w")))))) ;; ----------------------------------------------------------------------------- (define (scheme-report-environment version) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index de956060..0222c45d 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -755,6 +755,20 @@ (lambda (data port) (port.write_u8_vector data))) +;; ----------------------------------------------------------------------------- +(define open-binary-output-file + (let ((open)) + (lambda (filename) + "(open-binary-output-file filename) + + Function open file and return port that can be used for writing. If file + exists it will throw an Error." + (typecheck "open-output-file" filename "string") + (if (not (procedure? open)) + (set! open (%fs-promisify-proc 'open "open-binary-output-file"))) + (if (file-exists? filename) + (throw (new Error "open-binary-output-file: file exists")) + (lips.OutputBinaryFilePort filename (open filename "w")))))) ;; ----------------------------------------------------------------------------- (define delete-file @@ -764,13 +778,9 @@ Function delete the file of given name." (typecheck "delete-file" filename "string") - (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) - (if (null? fs) - (throw (new Error "delete-file: fs not defined")) - (begin - (if (not (procedure? unlink)) - (set! unlink (promisify fs.unlink))) - (unlink filename))))))) + (if (not (procedure? unlink)) + (set! unlink (%fs-promisify-proc 'unlink "delete-file"))) + (unlink filename)))) ;; ----------------------------------------------------------------------------- (define (call-with-port port proc) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index dfdddc42..7d212a21 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1236,9 +1236,16 @@ (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) - (reject e)))))))))) - (if (not (null? fs)) - (--> lips.env (get '**internal-env**) (set "fs" fs)))) + (reject e))))))))) + (Buffer (cond ((eq? self global) + self.Buffer) + ((not (null? self.BrowserFS)) + (. (BrowserFS.BFSRequire "buffer") 'Buffer))))) + (let ((internal (lips.env.get '**internal-env**))) + (if (not (null? Buffer)) + (internal.set "Buffer" Buffer)) + (if (not (null? fs)) + (internal.set "fs" fs)))) ;; ----------------------------------------------------------------------------- (define (environment? obj) @@ -1296,6 +1303,17 @@ (define %read-binary-file (curry %read-file true)) (define %read-text-file (curry %read-file false)) +;; ----------------------------------------------------------------------------- +(define (%fs-promisify-proc fn message) + "(%fs-promisify-proc fn string) + + Function return promisified version of fs function or throw exception + if fs is not available." + (let ((fs (--> lips.env (get '**internal-env**) (get 'fs)))) + (if (null? fs) + (throw (new Error (string-append message ": fs not defined"))) + (promisify (. fs fn))))) + ;; ----------------------------------------------------------------------------- (define (response->content binary res) "(response->text binary res) diff --git a/src/lips.js b/src/lips.js index 28e419d5..8b078c50 100644 --- a/src/lips.js +++ b/src/lips.js @@ -5682,21 +5682,27 @@ } else { x = x.valueOf(); } - this.fs('write')(this._fd, x, function() { }); + this.fs().write(this._fd, x, function(err) { + if (err) { + throw err; + } + }); }; } OutputFilePort.prototype = Object.create(OutputPort.prototype); OutputFilePort.prototype.constructor = OutputFilePort; - OutputFilePort.prototype.fs = function(name) { - var fs = user_env.get('**internal-env**').get('fs'); - if (!fs) { - throw new Error(`${name}: fs is not defined`); + OutputFilePort.prototype.fs = function() { + if (!this._fs) { + this._fs = this.internal('fs'); } - return fs[name]; + return this._fs; + }; + OutputFilePort.prototype.internal = function(name) { + return user_env.get('**internal-env**').get(name); }; OutputFilePort.prototype.close = function() { return new Promise((resolve, reject) => { - this.fs('close')(this._fd, (err) => { + this.fs().close(this._fd, (err) => { if (err) { reject(err); } else { @@ -5821,6 +5827,14 @@ } read_only(this, '__type__', binary_port); read_only(this, '_buffer', [], { hidden: true }); + this.write = function(x) { + typecheck('write', x, ['number', 'uint8array']); + if (LNumber.isNumber(x)) { + this._buffer.push(x.valueOf()); + } else { + this._buffer.push(...Array.from(x)); + } + }; Object.defineProperty(this, '__buffer__', { enumerable: true, get: function() { @@ -5830,14 +5844,22 @@ } 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(byte) { - var name = 'OutputByteVectorPort::write_u8'; - typecheck(name, byte, 'number'); - this._buffer.push(byte.valueOf()); + typecheck('OutputByteVectorPort::write_u8', byte, 'number'); + this.write(byte); }; OutputByteVectorPort.prototype.write_u8_vector = function(vector) { typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); - this._buffer.push(...Array.from(vector)); + this.write(vector); }; OutputByteVectorPort.prototype.toString = function() { return '#<output-port (bytevector)>'; @@ -5876,6 +5898,52 @@ return `#<input-binary-port (${this.__filename__})>`; }; // ------------------------------------------------------------------------- + function OutputBinaryFilePort(filename, fd) { + if (typeof this !== 'undefined' && !(this instanceof OutputBinaryFilePort) || + typeof this === 'undefined') { + return new OutputBinaryFilePort(filename, fd); + } + typecheck('OutputBinaryFilePort', filename, 'string'); + read_only(this, '__filename__', filename); + read_only(this, '_fd', fd.valueOf(), { hidden: true }); + read_only(this, '__type__', binary_port); + var fs, Buffer; + this.write = function(x) { + typecheck('write', x, ['number', 'uint8array']); + var buffer; + if (!fs) { + fs = this.internal('fs'); + } + if (!Buffer) { + Buffer = this.internal('Buffer'); + } + if (LNumber.isNumber(x)) { + buffer = Buffer.from([x.valueOf()]); + } else { + buffer = Buffer.from(Array.from(x)); + } + return new Promise((resolve, reject) => { + fs.write(this._fd, buffer, function(err) { + if (err) { + reject(err); + } else { + resolve(); + } + }); + }); + }; + } + OutputBinaryFilePort.prototype = Object.create(OutputFilePort.prototype); + OutputBinaryFilePort.prototype.constructor = OutputBinaryFilePort; + OutputBinaryFilePort.prototype.write_u8 = function(byte) { + typecheck('OutputByteVectorPort::write_u8', byte, 'number'); + this.write(byte); + }; + OutputBinaryFilePort.prototype.write_u8_vector = function(vector) { + typecheck('OutputByteVectorPort::write_u8_vector', vector, 'uint8array'); + this.write(vector); + }; + // ------------------------------------------------------------------------- const binary_port = Symbol.for('binary'); const text_port = Symbol.for('text'); var eof = new EOF(); @@ -9655,6 +9723,7 @@ You can also use (help name) to display help for specic function or macro and InputByteVectorPort, OutputByteVectorPort, InputBinaryFilePort, + OutputBinaryFilePort, Formatter, Parser, diff --git a/tests/ports.scm b/tests/ports.scm index ae6088c9..20220df9 100644 --- a/tests/ports.scm +++ b/tests/ports.scm @@ -224,18 +224,21 @@ (test "ports: textual-port?" (lambda (t) - (let* ((closable (list (open-input-file "./tests/ports.scm") - (open-input-string "xxx") - (open-output-string) - (open-output-file "./tests/__x6__.scm"))) - (ports (append (list (current-input-port) - (current-output-port)) - closable))) - (for-each (lambda (p) - (t.is (textual-port? p) true)) - ports) - (for-each close-port closable) - (delete-file "./tests/__x6__.scm")))) + (let ((filename "./tests/__x6__.scm")) + (if (file-exists? filename) + (delete-file filename)) + (let* ((closable (list (open-input-file "./tests/ports.scm") + (open-input-string "xxx") + (open-output-string) + (open-output-file filename))) + (ports (append (list (current-input-port) + (current-output-port)) + closable))) + (for-each (lambda (p) + (t.is (textual-port? p) true)) + ports) + (for-each close-port closable) + (delete-file filename))))) (test "ports: read binary" (lambda (t) @@ -264,4 +267,30 @@ (write-u8 (char->integer #\space) port) (write-bytevector (string->utf8 "world") port) (let ((u8 (get-output-bytevector port))) - (t.is (utf8->string u8) "hello world"))))) + (t.is (utf8->string u8) "hello world")) + (close-port port) + (t.is (to.throw (write-u8 (char->integer #\!) port)) + true) + (t.is (to.throw (get-output-bytevector port)) + true)))) + +(test "ports: output binary file port" + (lambda (t) + (let ((fname "./tests/__x7__.scm") + (str "hello, world!\n")) + (if (file-exists? fname) + (delete-file fname)) + (let ((port (open-binary-output-file fname))) + (call-with-port port + (lambda (p) + (write-bytevector (string->utf8 str) p))) + (t.is (to.throw (write-u8 10 port)) + true) + (t.is (with-input-from-file fname + (lambda () + (let loop ((c (read-char)) (a '())) + (if (eof-object? c) + (list->string (reverse a)) + (loop (read-char) (cons c a)))))) + str) + (delete-file fname))))) From c69adf65365f6105a6d6a075a82acc747b7039cb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 6 Mar 2021 16:00:33 +0100 Subject: [PATCH 086/109] typecheck textual port procedures #132 --- README.md | 4 +- dist/lips.js | 129 ++++++++++++++++++++++++++++------------------- dist/lips.min.js | 4 +- src/lips.js | 40 +++++++++------ 4 files changed, 106 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 102c817f..37155ce0 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&164fb31e5d946c7f1a40473edd00c9049e2b7ace)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&05f17e62b8878f9ec268a2f2c28fc2a9)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&a85d1640eafb254a733133d657cd8498b6cd2adb)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0e72f4c54731229493aa0ad580464f17)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 8a4e1560..8dd82a53 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 11:33:45 +0000 + * build: Sat, 06 Mar 2021 15:00:04 +0000 */ (function () { 'use strict'; @@ -9870,135 +9870,151 @@ 'null': null, 'NaN': LNumber(NaN), // ------------------------------------------------------------------ - 'peek-char': doc('peek-char', function (port) { - if (port) { - typecheck('peek-char', port, ['input-port']); - } else { + 'peek-char': doc('peek-char', function () { + var port = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : null; + + if (port === null) { port = internal(this, 'stdin'); } + typecheck_text_port('peek-char', port, 'input-port'); return port.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 (port) { - if (typeof port === 'undefined') { + 'read-line': doc('read-line', function () { + var port = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : null; + + if (port === null) { port = internal(this, 'stdin'); } - typecheck('read-line', port, ['input-port']); + typecheck_text_port('read-line', port, 'input-port'); return port.read_line(); }, "(read-char port)\n\n Function read next character from input port."), // ------------------------------------------------------------------ - 'read-char': doc('read-char', function (port) { - if (typeof port === 'undefined') { + 'read-char': doc('read-char', function () { + var port = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : null; + + if (port === null) { port = internal(this, 'stdin'); } - typecheck('read-char', port, ['input-port', 'input-string-port']); + typecheck_text_port('read-char', port, 'input-port'); return port.read_char(); }, "(read-char port)\n\n Function read next character from input port."), // ------------------------------------------------------------------ read: doc( /*#__PURE__*/function () { - var _read2 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11(arg) { - var _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, value, port; + var _read2 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee11() { + var arg, + _iteratorNormalCompletion2, + _didIteratorError2, + _iteratorError2, + _iterator2, + _step2, + _value2, + value, + port, + _args13 = arguments; return regenerator.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: + arg = _args13.length > 0 && _args13[0] !== undefined$1 ? _args13[0] : null; + if (!LString.isString(arg)) { - _context11.next = 34; + _context11.next = 35; break; } _iteratorNormalCompletion2 = true; _didIteratorError2 = false; - _context11.prev = 3; + _context11.prev = 4; _iterator2 = asyncIterator(parse(arg, this)); - case 5: - _context11.next = 7; + case 6: + _context11.next = 8; return _iterator2.next(); - case 7: + case 8: _step2 = _context11.sent; _iteratorNormalCompletion2 = _step2.done; - _context11.next = 11; + _context11.next = 12; return _step2.value; - case 11: + case 12: _value2 = _context11.sent; if (_iteratorNormalCompletion2) { - _context11.next = 18; + _context11.next = 19; break; } value = _value2; return _context11.abrupt("return", value); - case 15: + case 16: _iteratorNormalCompletion2 = true; - _context11.next = 5; + _context11.next = 6; break; - case 18: - _context11.next = 24; + case 19: + _context11.next = 25; break; - case 20: - _context11.prev = 20; - _context11.t0 = _context11["catch"](3); + case 21: + _context11.prev = 21; + _context11.t0 = _context11["catch"](4); _didIteratorError2 = true; _iteratorError2 = _context11.t0; - case 24: - _context11.prev = 24; + case 25: _context11.prev = 25; + _context11.prev = 26; if (!(!_iteratorNormalCompletion2 && _iterator2["return"] != null)) { - _context11.next = 29; + _context11.next = 30; break; } - _context11.next = 29; + _context11.next = 30; return _iterator2["return"](); - case 29: - _context11.prev = 29; + case 30: + _context11.prev = 30; if (!_didIteratorError2) { - _context11.next = 32; + _context11.next = 33; break; } throw _iteratorError2; - case 32: - return _context11.finish(29); - case 33: - return _context11.finish(24); + return _context11.finish(30); case 34: - if (arg) { - typecheck('read', arg, 'input-port'); - port = arg; - } else { + return _context11.finish(25); + + case 35: + if (arg === null) { port = internal(this, 'stdin'); + } else { + port = arg; } + typecheck_text_port('read', arg, 'input-port'); return _context11.abrupt("return", port.read.call(this)); - case 36: + case 38: case "end": return _context11.stop(); } } - }, _callee11, this, [[3, 20, 24, 34], [25,, 29, 33]]); + }, _callee11, this, [[4, 21, 25, 35], [26,, 30, 34]]); })); - function read(_x9) { + function read() { return _read2.apply(this, arguments); } @@ -10529,7 +10545,7 @@ }, _callee13, this); })); - return function (_x10, _x11) { + return function (_x9, _x10) { return _ref30.apply(this, arguments); }; }()), "(do ((<var> <init> <next>)) (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."), @@ -12639,6 +12655,15 @@ } // ------------------------------------------------------------------------- + function typecheck_text_port(fn, arg, type) { + typecheck(fn, arg, type); + + if (arg.__type__ === binary_port) { + throw new Error(typeErrorMessage(fn, 'binary-port', 'textual-port')); + } + } // ------------------------------------------------------------------------- + + function typecheck(fn, arg, expected) { var position = arguments.length > 3 && arguments[3] !== undefined$1 ? arguments[3] : null; fn = fn.valueOf(); @@ -12805,7 +12830,7 @@ } } - function promise(_x12) { + function promise(_x11) { return _promise.apply(this, arguments); } @@ -13151,7 +13176,7 @@ } // ------------------------------------------------------------------------- - function exec(_x13, _x14, _x15) { + function exec(_x12, _x13, _x14) { return _exec.apply(this, arguments); } // ------------------------------------------------------------------------- @@ -13636,10 +13661,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 06 Mar 2021 11:33:45 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 06 Mar 2021 15:00:04 +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('Sat, 06 Mar 2021 11:33:45 +0000').valueOf(); + var date = LString('Sat, 06 Mar 2021 15:00:04 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13679,7 +13704,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 06 Mar 2021 11:33:45 +0000', + date: 'Sat, 06 Mar 2021 15:00:04 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 88df27be..64a48b4e 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 11:33:45 +0000 + * build: Sat, 06 Mar 2021 15:00:04 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(e){if(e){typecheck("peek-char",e,["input-port"])}else{e=internal(this,"stdin")}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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("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(e){if(typeof e==="undefined"){e=internal(this,"stdin")}typecheck("read-char",e,["input-port","input-string-port"]);return e.read_char()},"(read-char port)\n\n Function read next character from input port."),read:doc(function(){var r=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:if(!LString.isString(t)){r.next=34;break}n=true;i=false;r.prev=3;u=asyncIterator(parse(t,this));case 5:r.next=7;return u.next();case 7:o=r.sent;n=o.done;r.next=11;return o.value;case 11:c=r.sent;if(n){r.next=18;break}s=c;return r.abrupt("return",s);case 15:n=true;r.next=5;break;case 18:r.next=24;break;case 20:r.prev=20;r.t0=r["catch"](3);i=true;a=r.t0;case 24:r.prev=24;r.prev=25;if(!(!n&&u["return"]!=null)){r.next=29;break}r.next=29;return u["return"]();case 29:r.prev=29;if(!i){r.next=32;break}throw a;case 32:return r.finish(29);case 33:return r.finish(24);case 34:if(t){typecheck("read",t,"input-port");l=t}else{l=internal(this,"stdin")}return r.abrupt("return",l.read.call(this));case 36:case"end":return r.stop()}}},e,this,[[3,20,24,34],[25,,29,33]])}));function e(e){return r.apply(this,arguments)}return e}(),"(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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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(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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 11:33:45 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 11:33:45 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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",t,"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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 15:00:04 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 15:00:04 +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/src/lips.js b/src/lips.js index 8b078c50..cf38fd40 100644 --- a/src/lips.js +++ b/src/lips.js @@ -6399,51 +6399,50 @@ 'null': null, 'NaN': LNumber(NaN), // ------------------------------------------------------------------ - 'peek-char': doc('peek-char', function(port) { - if (port) { - typecheck('peek-char', port, ['input-port']); - } else { + 'peek-char': doc('peek-char', function(port = null) { + if (port === null) { port = internal(this, 'stdin'); } + typecheck_text_port('peek-char', port, 'input-port'); return port.peek_char(); }, `(peek-char port) Function get character from string port or EOF object if no more data in string port.`), // ------------------------------------------------------------------ - 'read-line': doc('read-line', function(port) { - if (typeof port === 'undefined') { + 'read-line': doc('read-line', function(port = null) { + if (port === null) { port = internal(this, 'stdin'); } - typecheck('read-line', port, ['input-port']); + typecheck_text_port('read-line', port, 'input-port'); return port.read_line(); }, `(read-char port) Function read next character from input port.`), // ------------------------------------------------------------------ - 'read-char': doc('read-char', function(port) { - if (typeof port === 'undefined') { + 'read-char': doc('read-char', function(port = null) { + if (port === null) { port = internal(this, 'stdin'); } - typecheck('read-char', port, ['input-port', 'input-string-port']); + typecheck_text_port('read-char', port, 'input-port'); return port.read_char(); }, `(read-char port) Function read next character from input port.`), // ------------------------------------------------------------------ - read: doc(async function read(arg) { + read: doc(async function read(arg = null) { if (LString.isString(arg)) { for await (let value of parse(arg, this)) { return value; } } var port; - if (arg) { - typecheck('read', arg, 'input-port'); - port = arg; - } else { + if (arg === null) { port = internal(this, 'stdin'); + } else { + port = arg; } + typecheck_text_port('read', arg, 'input-port'); return port.read.call(this); }, `(read [string]) @@ -8966,6 +8965,17 @@ }); } // ------------------------------------------------------------------------- + function typecheck_text_port(fn, arg, type) { + typecheck(fn, arg, type); + if (arg.__type__ === binary_port) { + throw new Error(typeErrorMessage( + fn, + 'binary-port', + 'textual-port' + )); + } + } + // ------------------------------------------------------------------------- function typecheck(fn, arg, expected, position = null) { fn = fn.valueOf(); const arg_type = type(arg).toLowerCase(); From 44d1dd7c6c3b8fc8e655496913afd730999e9b14 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 6 Mar 2021 16:25:43 +0100 Subject: [PATCH 087/109] add `read-bytevector!` function #132 --- dist/std.min.scm | 3 ++- dist/std.scm | 27 ++++++++++++++++++++++++++- lib/R7RS.scm | 25 +++++++++++++++++++++++++ lib/byte-vectors.scm | 2 +- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index 69fd6c11..c4fba2d2 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -251,7 +251,7 @@ (define (file-exists? filename) (new Promise (lambda (resolve) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "file-exists?: fs not defined")) (fs.stat filename (lambda (err stat) (if (null? err) (resolve (stat.isFile)) (resolve #f))))))))) (define open-output-file (let ((open)) (lambda (filename) "(open-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (if (not (procedure? open)) (set! open (%fs-promisify-proc (quote open) "open-output-file"))) (if (file-exists? filename) (throw (new Error "open-output-file: file exists")) (lips.OutputFilePort filename (open filename "w")))))) (define (scheme-report-environment version) "(scheme-report-environment version)\u000A\u000AFunction return new Environment object for given Scheme Spec version.\u000AOnly argument 5 is supported that create environemnt for R5RS." (typecheck "scheme-report-environment" version "number") (case version ((5) (%make-env "R5RS" * + - / < <= = > >= abs acos and angle append apply asin assoc assq assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar cadadr cadar caddar cadddr caddr cadr call-with-current-continuation call-with-input-file call-with-output-file call-with-values car case cdaaar cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cond cons cos current-input-port current-output-port define define-syntax delay denominator display do dynamic-wind eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt floor for-each force gcd if imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lambda lcm length let let* let-syntax letrec letrec-syntax list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector map max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file or output-port? pair? peek-char positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? tan truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! vector? with-input-from-file with-output-to-file write write-char zero?)) ((7) (throw (new Error "not yet implemented"))) (else (throw (new Error (string-append "scheme-report-environment: version " (number->string version) " not supported")))))) -(define-macro (%make-vector prefix type help) "(%make-vector prefix type help)\u000A\u000AMega helper macro that create list of functions for single byte vector\u000Abased on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...)\u000A\u000ACreate ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v)\u000A\u000Areturn length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a v1 v2 ...)\u000A\u000AAllocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x)\u000A\u000AFunction return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k)\u000A\u000AFunction set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote)))))))) +(define-macro (%make-vector prefix type help) "(%make-vector prefix type help)\u000A\u000AMega helper macro that create list of functions for single byte vector\u000Abased on typed array from JavaScript" (letrec ((prefix-str (symbol->string prefix)) (type-str (symbol->string type)) (l-type (--> type-str (toLowerCase))) (static (lambda (name) (string->symbol (format "~a.~a" type-str name)))) (TypedArray.from (static "from")) (fn-name (lambda (str) (string->symbol (format str prefix-str)))) (type-vector (fn-name "~avector")) (make-vector (fn-name "make-~avector")) (vector? (fn-name "~avector?")) (vector-in-range? (fn-name "%~avector-in-range?")) (vector-ref (fn-name "~avector-ref")) (repr-str (format "#~a" prefix-str)) (vector-length (fn-name "~avector-length")) (vector->list (fn-name "~avector->list")) (vector-set! (fn-name "~avector-set!")) (list->tvector (fn-name "list->~avector")) (vector->tvector (fn-name "vector->~avector"))) (quasiquote (begin (define ((unquote type-vector) . args) (unquote (format "(~a v1 v2 ...)\u000A\u000ACreate ~a from give arguments." type-vector help)) ((unquote TypedArray.from) (list->vector args))) (define ((unquote vector-length) v) (unquote (format "(~a v)\u000A\u000Areturn length of ~a." vector-length help)) (typecheck (unquote (symbol->string vector-length)) v (unquote l-type)) v.length) (define ((unquote make-vector) k . fill) (unquote (format "(~a k fill)\u000A\u000AAllocate new ~a of length k, with optional initial values." make-vector help)) (let ((v (new (unquote type) k))) (if (not (null? fill)) (--> v (fill (car fill)))) v)) (define ((unquote vector?) x) (unquote (format "(~a x)\u000A\u000AFunction return #t of argument is ~a otherwise it return #f." vector? help)) (and (object? x) (equal? (. x (quote constructor)) (unquote type)))) (define ((unquote vector-in-range?) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction test if index is range for ~a." vector-in-range? help)) (typecheck (unquote (symbol->string vector-in-range?)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-in-range?)) k "number") (let ((len (length vector))) (and (>= k 0) (< k len)))) (define ((unquote vector-ref) vector k) (unquote (format "(~a vector k)\u000A\u000AFunction return value frome vector at index k. If index is out of range it throw exception." vector-ref help)) (typecheck (unquote (symbol->string vector-ref)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-ref)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-ref)))) (. vector k))) (define ((unquote vector->list) vector) (typecheck (unquote (symbol->string vector->list)) vector (unquote l-type)) (vector->list (Array.from vector))) (define ((unquote vector-set!) vector k v) (unquote (format "(~a vector k)\u000A\u000AFunction set value of ~a at index k. If index is out of range it throw exception." vector-set! help)) (typecheck (unquote (symbol->string vector-set!)) vector (unquote l-type)) (typecheck (unquote (symbol->string vector-set!)) k "number") (if (not ((unquote vector-in-range?) vector k)) (throw (new Error (unquote (format "~a index out of range" vector-set!)))) (set-obj! vector k v))) (define ((unquote list->tvector) lst) (typecheck (unquote (symbol->string list->tvector)) lst "pair") (apply (unquote vector) lst)) (define ((unquote vector->tvector) vector) (typecheck (unquote (symbol->string vector->tvector)) vector "array") ((unquote TypedArray.from) vector)) (set-special! (unquote repr-str) (quote (unquote type-vector)) lips.specials.SPLICE) (set-repr! (unquote type) (lambda (x _quote) (string-append (unquote repr-str) (repr ((unquote vector->list) x) _quote)))))))) (%make-vector u8 Uint8Array "usigned 8-bit integer vector") (%make-vector s8 Int8Array "signed 8-bit integer vector") (%make-vector u16 Uint16Array "usigned 16-bit integer vector") @@ -325,6 +325,7 @@ (%define-binary-output-lambda write-u8 "number" "(write-u8 byte)\u000A(write-u8 byte port)\u000A\u000AWrite byte into binary output port." (lambda (data port) (port.write_u8 data))) (%define-binary-output-lambda write-bytevector "uint8array" "(write-bytevector bytevector)\u000A(write-bytevector bytevector port)\u000A\u000AWrite byte vector into binary output port." (lambda (data port) (port.write_u8_vector data))) (define open-binary-output-file (let ((open)) (lambda (filename) "(open-binary-output-file filename)\u000A\u000AFunction open file and return port that can be used for writing. If file\u000Aexists it will throw an Error." (typecheck "open-output-file" filename "string") (if (not (procedure? open)) (set! open (%fs-promisify-proc (quote open) "open-binary-output-file"))) (if (file-exists? filename) (throw (new Error "open-binary-output-file: file exists")) (lips.OutputBinaryFilePort filename (open filename "w")))))) +(define (read-bytevector! vector . rest) "(read-bytevector! bytevector)\u000A(read-bytevector! bytevector port)\u000A(read-bytevector! bytevector port start)\u000A(read-bytevector! bytevector port start end)\u000A\u000AFunction read next bytes from binary input port and write them into byte vector.\u000Aif not start is specified it start to write into 0 position of the vector until\u000Athe end or end the vector if no end is specified." (typecheck "read-bytevector!" vector "uint8array") (let ((port (if (null? rest) (current-input-port) (car rest))) (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) (bytevector-length vector) (caddr rest)))) (typecheck "read-bytevector!" port "input-port") (if (not (binary-port? port)) (throw (new Error "read-bytevector!: invalid port. Binary port required.")) (begin (typecheck "read-bytevector!" start "number") (typecheck "read-bytevector!" end "number") (let ((out (read-bytevector (- end start) port))) (vector.set out start end)))))) (define delete-file (let ((unlink #f)) (lambda (filename) "(delete-file filename)\u000A\u000AFunction delete the file of given name." (typecheck "delete-file" filename "string") (if (not (procedure? unlink)) (set! unlink (%fs-promisify-proc (quote unlink) "delete-file"))) (unlink filename)))) (define (call-with-port port proc) "(call-with-port port proc)\u000A\u000AProc is executed with given port and after it returns, the port is closed." (try (proc port) (finally (if (procedure? port.close) (port.close))))) (define (close-port port) "(close-port port)\u000A\u000AClose input or output port." (typecheck "close-port" port #("input-port" "output-port")) (port.close)) diff --git a/dist/std.scm b/dist/std.scm index e6fd5a68..077702f2 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2843,7 +2843,7 @@ v.length) ;; ----------------------------------------------------------------------------- (define (,make-vector k . fill) - ,(format "(~a v1 v2 ...) + ,(format "(~a k fill) Allocate new ~a of length k, with optional initial values." make-vector @@ -3698,6 +3698,31 @@ (throw (new Error "open-binary-output-file: file exists")) (lips.OutputBinaryFilePort filename (open filename "w")))))) +;; ----------------------------------------------------------------------------- +(define (read-bytevector! vector . rest) + "(read-bytevector! bytevector) + (read-bytevector! bytevector port) + (read-bytevector! bytevector port start) + (read-bytevector! bytevector port start end) + + Function read next bytes from binary input port and write them into byte vector. + if not start is specified it start to write into 0 position of the vector until + the end or end the vector if no end is specified." + (typecheck "read-bytevector!" vector "uint8array") + (let ((port (if (null? rest) (current-input-port) (car rest))) + (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) + (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) + (bytevector-length vector) + (caddr rest)))) + (typecheck "read-bytevector!" port "input-port") + (if (not (binary-port? port)) + (throw (new Error "read-bytevector!: invalid port. Binary port required.")) + (begin + (typecheck "read-bytevector!" start "number") + (typecheck "read-bytevector!" end "number") + (let ((out (read-bytevector (- end start) port))) + (vector.set out start end)))))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 0222c45d..a9691972 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -770,6 +770,31 @@ (throw (new Error "open-binary-output-file: file exists")) (lips.OutputBinaryFilePort filename (open filename "w")))))) +;; ----------------------------------------------------------------------------- +(define (read-bytevector! vector . rest) + "(read-bytevector! bytevector) + (read-bytevector! bytevector port) + (read-bytevector! bytevector port start) + (read-bytevector! bytevector port start end) + + Function read next bytes from binary input port and write them into byte vector. + if not start is specified it start to write into 0 position of the vector until + the end or end the vector if no end is specified." + (typecheck "read-bytevector!" vector "uint8array") + (let ((port (if (null? rest) (current-input-port) (car rest))) + (start (if (or (null? rest) (null? (cdr rest))) 0 (cadr rest))) + (end (if (or (null? rest) (null? (cdr rest)) (null? (cddr rest))) + (bytevector-length vector) + (caddr rest)))) + (typecheck "read-bytevector!" port "input-port") + (if (not (binary-port? port)) + (throw (new Error "read-bytevector!: invalid port. Binary port required.")) + (begin + (typecheck "read-bytevector!" start "number") + (typecheck "read-bytevector!" end "number") + (let ((out (read-bytevector (- end start) port))) + (vector.set out start end)))))) + ;; ----------------------------------------------------------------------------- (define delete-file (let ((unlink #f)) diff --git a/lib/byte-vectors.scm b/lib/byte-vectors.scm index 28e297b5..2a66e49e 100644 --- a/lib/byte-vectors.scm +++ b/lib/byte-vectors.scm @@ -51,7 +51,7 @@ v.length) ;; ----------------------------------------------------------------------------- (define (,make-vector k . fill) - ,(format "(~a v1 v2 ...) + ,(format "(~a k fill) Allocate new ~a of length k, with optional initial values." make-vector From 1a378e66c37acabe4e82a081d75d4abca86a0b6c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 6 Mar 2021 16:27:01 +0100 Subject: [PATCH 088/109] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2a5838..2157d540 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ * add `current-directory` and `set-...` from SRFI-170 * add gensym literals (e.g. `#:foo`) * fix pretty print of different cases of `let` +* add binary input/output procedures from R7RS ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string From 2b4f6d6779f9a0313b144cb909f1cbf1c0f36b5c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sat, 6 Mar 2021 16:48:10 +0100 Subject: [PATCH 089/109] fix typechecking of read function --- README.md | 2 +- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 37155ce0..b446a87c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&a85d1640eafb254a733133d657cd8498b6cd2adb)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&1a378e66c37acabe4e82a081d75d4abca86a0b6c)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0e72f4c54731229493aa0ad580464f17)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 8dd82a53..46491102 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 15:00:04 +0000 + * build: Sat, 06 Mar 2021 15:47:29 +0000 */ (function () { 'use strict'; @@ -10003,7 +10003,7 @@ port = arg; } - typecheck_text_port('read', arg, 'input-port'); + typecheck_text_port('read', port, 'input-port'); return _context11.abrupt("return", port.read.call(this)); case 38: @@ -13661,10 +13661,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 06 Mar 2021 15:00:04 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sat, 06 Mar 2021 15:47:29 +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('Sat, 06 Mar 2021 15:00:04 +0000').valueOf(); + var date = LString('Sat, 06 Mar 2021 15:47:29 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13704,7 +13704,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 06 Mar 2021 15:00:04 +0000', + date: 'Sat, 06 Mar 2021 15:47:29 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 64a48b4e..8dda4f88 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 15:00:04 +0000 + * build: Sat, 06 Mar 2021 15:47:29 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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",t,"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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 15:00:04 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 15:00:04 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 15:47:29 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 15:47:29 +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/src/lips.js b/src/lips.js index cf38fd40..e2b8289f 100644 --- a/src/lips.js +++ b/src/lips.js @@ -6442,7 +6442,7 @@ } else { port = arg; } - typecheck_text_port('read', arg, 'input-port'); + typecheck_text_port('read', port, 'input-port'); return port.read.call(this); }, `(read [string]) From 9d5c5131ae627929aa64878fb2554ae58b6279cd Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 13:24:40 +0100 Subject: [PATCH 090/109] fix formatter on multiline strings and atoms --- CHANGELOG.md | 1 + README.md | 4 +- dist/lips.js | 310 ++++++++++++++++++++--------------- dist/lips.min.js | 4 +- src/lips.js | 45 +++-- tests/formatter.scm | 17 +- tests/snapshots/test.js.md | 24 ++- tests/snapshots/test.js.snap | Bin 18164 -> 18197 bytes 8 files changed, 247 insertions(+), 158 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2157d540..005c4af6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * fix division on single argument (now `(/ n)` == `(/ 1 n)`) * fix complex operation that result in real (e.g. multiplication over conjugation) * fix `list-ref` according to R7RS errata +* fix formatter (pretty print) on multiline strings and atoms ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index b446a87c..91cc2022 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&1a378e66c37acabe4e82a081d75d4abca86a0b6c)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&0e72f4c54731229493aa0ad580464f17)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&c42e3ec54ca2e2a2bf65240e00bbd03b32a3583f)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&37d92ca40f03da1d26598c0ee49db9a2)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 46491102..fa6fdd16 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 15:47:29 +0000 + * build: Sun, 07 Mar 2021 12:25:17 +0000 */ (function () { 'use strict'; @@ -1330,7 +1330,7 @@ function is_debug() { - return user_env.get('DEBUG', { + return user_env && user_env.get('DEBUG', { throwError: false }); } @@ -2551,7 +2551,7 @@ this._newline = i + 1; } - if (this._whitespace) { + if (this._whitespace && this._state === null) { this._next = i + 1; this._col = this._i - newline; return true; @@ -3609,6 +3609,29 @@ (!next_pattern || match(next_pattern, [input[i]])); } */ + function get_first_match(patterns, input) { + var _iterator5 = _createForOfIteratorHelper(patterns), + _step5; + + try { + for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { + var _p = _step5.value; + + var _m = inner_match(_p, input); + + if (_m !== -1) { + return _m; + } + } + } catch (err) { + _iterator5.e(err); + } finally { + _iterator5.f(); + } + + return -1; + } + function not_symbol_match() { return pattern[p] === Symbol["for"]('symbol') && !is_symbol_string(input[i]); } @@ -3635,7 +3658,7 @@ if (['+', '*'].includes(pattern[p].flag)) { while (i < input.length) { - m = inner_match(pattern[p].pattern, input.slice(i)); + m = get_first_match(pattern[p].patterns, input.slice(i)); if (m === -1) { break; @@ -3648,7 +3671,7 @@ p++; continue; } else if (pattern[p].flag === '?') { - m = inner_match(pattern[p].pattern, input.slice(i)); + m = get_first_match(pattern[p].patterns, input.slice(i)); if (m === -1) { i -= 2; // if not found use same test on same input again @@ -3785,21 +3808,21 @@ return false; } - var _iterator5 = _createForOfIteratorHelper(regexes), - _step5; + var _iterator6 = _createForOfIteratorHelper(regexes), + _step6; try { - for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { - var re = _step5.value; + for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { + var re = _step6.value; if (token.match(re)) { return true; } } } catch (err) { - _iterator5.e(err); + _iterator6.e(err); } finally { - _iterator5.f(); + _iterator6.f(); } } @@ -3909,27 +3932,38 @@ Ahead.prototype.match = function (string) { return string.match(this.pattern); }; // ---------------------------------------------------------------------- + // Pattern have any number of patterns that is match using OR operator + // pattern is in form of array with regular expressions + // ---------------------------------------------------------------------- - function Pattern(pattern, flag) { - this.pattern = pattern; - this.flag = flag; - } // TODO: make it print + function Pattern() { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + var flag = args.pop(); + this.patterns = args; + this.flag = flag; + } Pattern.prototype.toString = function () { - return "#<pattern(".concat(this.pattern, " ").concat(this.flag, ")>"); + var patterns = this.patterns.map(function (x) { + return toString(x); + }).join('|'); + return "#<pattern(".concat(patterns, " ").concat(this.flag, ")>"); }; // ---------------------------------------------------------------------- Formatter.Pattern = Pattern; Formatter.Ahead = Ahead; - var p_o = /[[(]/; - var p_e = /[\])]/; + var p_o = /^[[(]$/; + var p_e = /^[\])]$/; var not_p = /[^()[\]]/; var not_close = new Ahead(/[^)\]]/); //const open = 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')], '*'); @@ -3942,31 +3976,33 @@ var non_def = /^(?!.*\b(?:[()[\]]|define|let(?:\*|rec|-env|-syntax)?|lambda|syntax-rules)\b).*$/; /* eslint-enable */ - var let_re = /^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/; + var let_re = /^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/; // match keyword if it's normal token or gensym (prefixed with #:) function keywords_re() { - for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { - args[_key3] = arguments[_key3]; + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; } return new RegExp("^(?:#:)?(?:".concat(args.join('|'), ")$")); } // line breaking rules - Formatter.rules = [[[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], //[[p_o, let_re, p_o, let_value], 1, not_close], - //s[[p_o, let_re, p_o, let_value, p_e, sexp], 0, not_close], + Formatter.rules = [[[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], [[p_o, let_re, symbol, sexp, sexp_or_atom], 0, not_close], //[[p_o, let_re, p_o, let_value], 1, not_close], [[p_o, keywords_re('define-syntax'), /.+/], 1], [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, not_close], [[p_o, let_re, sexp], 1, not_close], [[p_o, keywords_re('lambda', 'if'), not_p], 1, not_close], [[p_o, keywords_re('while'), not_p, sexp], 1, not_close], [[p_o, keywords_re('if'), not_p, glob], 1], [[p_o, def_lambda_re, identifiers], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re], 1, not_close], [[p_o, def_lambda_re, identifiers, string_re, sexp], 1, not_close], [[p_o, def_lambda_re, identifiers, sexp], 1, not_close]]; // ---------------------------------------------------------------------- Formatter.prototype["break"] = function () { - var code = this.__code__.replace(/\n[ \t]*/g, '\n '); + var code = this.__code__.replace(/\n[ \t]*/g, '\n '); // function that work when calling tokenize with meta data or not + var token = function token(t) { - if (t.token.match(string_re)) { + if (t.token.match(string_re) || t.token.match(re_re)) { return t.token; } else { return t.token.replace(/\s+/, ' '); } - }; + }; // tokenize is part of the parser/lexer that split code into tokens and inclue + // meta data like number of column or line + var tokens = tokenize(code, true).map(token).filter(function (t) { return t !== '\n'; @@ -3983,24 +4019,26 @@ rules.map(function (b) { return b[1]; }).forEach(function (count) { - count = count.valueOf(); + count = count.valueOf(); // some patterns require to check what was before like + // if inside let binding if (count > 0 && !sexp[count]) { sexp[count] = previousSexp(sub, count); } }); - var _iterator6 = _createForOfIteratorHelper(rules), - _step6; + var _iterator7 = _createForOfIteratorHelper(rules), + _step7; try { - for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) { - var _step6$value = slicedToArray(_step6.value, 3), - pattern = _step6$value[0], - count = _step6$value[1], - ext = _step6$value[2]; + for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { + var _step7$value = slicedToArray(_step7.value, 3), + pattern = _step7$value[0], + count = _step7$value[1], + ext = _step7$value[2]; + + count = count.valueOf(); // 0 count mean ignore the previous S-Expression - count = count.valueOf(); var test_sexp = count > 0 ? sexp[count] : sub; var m = match(pattern, test_sexp.filter(function (t) { return t.trim(); @@ -4021,9 +4059,9 @@ } } } catch (err) { - _iterator6.e(err); + _iterator7.e(err); } finally { - _iterator6.f(); + _iterator7.f(); } } @@ -4690,8 +4728,8 @@ var cls = obj.constructor; if (instances.has(cls)) { - for (var _len4 = arguments.length, pair_args = new Array(_len4 > 3 ? _len4 - 3 : 0), _key4 = 3; _key4 < _len4; _key4++) { - pair_args[_key4 - 3] = arguments[_key4]; + for (var _len5 = arguments.length, pair_args = new Array(_len5 > 3 ? _len5 - 3 : 0), _key5 = 3; _key5 < _len5; _key5++) { + pair_args[_key5 - 3] = arguments[_key5]; } return instances.get(cls)(obj, { @@ -6825,8 +6863,8 @@ function guardMathCall(fn) { - for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { - args[_key5 - 1] = arguments[_key5]; + for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) { + args[_key6 - 1] = arguments[_key6]; } args.forEach(function (arg) { @@ -6839,16 +6877,16 @@ function pipe() { var _this4 = this; - for (var _len6 = arguments.length, fns = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { - fns[_key6] = arguments[_key6]; + for (var _len7 = arguments.length, fns = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { + fns[_key7] = arguments[_key7]; } fns.forEach(function (fn, i) { typecheck('pipe', fn, 'function', i + 1); }); return function () { - for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { - args[_key7] = arguments[_key7]; + for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { + args[_key8] = arguments[_key8]; } return fns.reduce(function (args, f) { @@ -6859,8 +6897,8 @@ function compose() { - for (var _len8 = arguments.length, fns = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { - fns[_key8] = arguments[_key8]; + for (var _len9 = arguments.length, fns = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { + fns[_key9] = arguments[_key9]; } fns.forEach(function (fn, i) { @@ -6877,8 +6915,8 @@ return function recur(fn, init) { typecheck(name, fn, 'function'); - for (var _len9 = arguments.length, lists = new Array(_len9 > 2 ? _len9 - 2 : 0), _key9 = 2; _key9 < _len9; _key9++) { - lists[_key9 - 2] = arguments[_key9]; + for (var _len10 = arguments.length, lists = new Array(_len10 > 2 ? _len10 - 2 : 0), _key10 = 2; _key10 < _len10; _key10++) { + lists[_key10 - 2] = arguments[_key10]; } if (lists.some(is_null)) { @@ -6907,8 +6945,8 @@ function reduceMathOp(fn) { var init = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : null; return function () { - for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { - args[_key10] = arguments[_key10]; + for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { + args[_key11] = arguments[_key11]; } if (init !== null) { @@ -6921,8 +6959,8 @@ function curry(fn) { - for (var _len11 = arguments.length, init_args = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) { - init_args[_key11 - 1] = arguments[_key11]; + for (var _len12 = arguments.length, init_args = new Array(_len12 > 1 ? _len12 - 1 : 0), _key12 = 1; _key12 < _len12; _key12++) { + init_args[_key12 - 1] = arguments[_key12]; } typecheck('curry', fn, 'function'); @@ -6931,8 +6969,8 @@ var args = init_args.slice(); function call() { - for (var _len12 = arguments.length, more_args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { - more_args[_key12] = arguments[_key12]; + for (var _len13 = arguments.length, more_args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { + more_args[_key13] = arguments[_key13]; } args = args.concat(more_args); @@ -6953,8 +6991,8 @@ function limit(n, fn) { typecheck('limit', fn, 'function', 2); return function () { - for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { - args[_key13] = arguments[_key13]; + for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { + args[_key14] = arguments[_key14]; } return fn.apply(void 0, toConsumableArray(args.slice(0, n))); @@ -7054,26 +7092,26 @@ var wrap = function wrap(fn) { return function () { - for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { - args[_key14] = arguments[_key14]; + for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { + args[_key15] = arguments[_key15]; } return fn.apply(this.__string__, args); }; }; - var _iterator7 = _createForOfIteratorHelper(_keys), - _step7; + var _iterator8 = _createForOfIteratorHelper(_keys), + _step8; try { - for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) { - var key = _step7.value; + for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { + var key = _step8.value; LString.prototype[key] = wrap(String.prototype[key]); } } catch (err) { - _iterator7.e(err); + _iterator8.e(err); } finally { - _iterator7.f(); + _iterator8.f(); } } @@ -8813,9 +8851,9 @@ return /*#__PURE__*/function () { var _ref26 = asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee10() { var parser, - _len15, + _len16, args, - _key15, + _key16, _args12 = arguments; return regenerator.wrap(function _callee10$(_context10) { @@ -8828,8 +8866,8 @@ case 2: parser = _context10.sent; - for (_len15 = _args12.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { - args[_key15] = _args12[_key15]; + for (_len16 = _args12.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) { + args[_key16] = _args12[_key16]; } return _context10.abrupt("return", fn.apply(void 0, [parser].concat(args))); @@ -9779,8 +9817,8 @@ var native_lambda = parse(tokenize("(lambda ()\n \"[native code]\"\n (throw \"Invalid Invocation\"))"))[0]; // ------------------------------------------------------------------------------- var get = doc(function get(object) { - for (var _len16 = arguments.length, args = new Array(_len16 > 1 ? _len16 - 1 : 0), _key16 = 1; _key16 < _len16; _key16++) { - args[_key16 - 1] = arguments[_key16]; + for (var _len17 = arguments.length, args = new Array(_len17 > 1 ? _len17 - 1 : 0), _key17 = 1; _key17 < _len17; _key17++) { + args[_key17 - 1] = arguments[_key17]; } // if arg is symbol someone probably want to get __fn__ from binded function @@ -10036,8 +10074,8 @@ var display = global_env.get('display'); var newline = global_env.get('newline'); - for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) { - args[_key17] = arguments[_key17]; + for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) { + args[_key18] = arguments[_key18]; } args.forEach(function (arg) { @@ -10047,8 +10085,8 @@ }, "(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."), // ------------------------------------------------------------------ 'format': doc(function format(str) { - for (var _len18 = arguments.length, args = new Array(_len18 > 1 ? _len18 - 1 : 0), _key18 = 1; _key18 < _len18; _key18++) { - args[_key18 - 1] = arguments[_key18]; + for (var _len19 = arguments.length, args = new Array(_len19 > 1 ? _len19 - 1 : 0), _key19 = 1; _key19 < _len19; _key19++) { + args[_key19 - 1] = arguments[_key19]; } typecheck('format', str, 'string'); @@ -10104,8 +10142,8 @@ var port = internal(this, 'stderr'); var repr = global_env.get('repr'); - for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) { - args[_key19] = arguments[_key19]; + for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) { + args[_key20] = arguments[_key20]; } var value = args.map(repr).join(' '); @@ -10737,8 +10775,8 @@ }, "(null-environment)\n\n Function return new base environment with std lib."), // ------------------------------------------------------------------ 'values': doc(function values() { - for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) { - args[_key20] = arguments[_key20]; + for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) { + args[_key21] = arguments[_key21]; } return Values(args); @@ -10837,8 +10875,8 @@ } // arguments and arguments.callee inside lambda function - for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) { - args[_key21] = arguments[_key21]; + for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) { + args[_key22] = arguments[_key22]; } if (this instanceof Environment) { @@ -11497,8 +11535,8 @@ append: doc(function append() { var _global_env$get; - for (var _len22 = arguments.length, items = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) { - items[_key22] = arguments[_key22]; + for (var _len23 = arguments.length, items = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { + items[_key23] = arguments[_key23]; } items = items.map(function (item) { @@ -11514,8 +11552,8 @@ 'append!': doc('append!', function () { var is_list = global_env.get('list?'); - for (var _len23 = arguments.length, items = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) { - items[_key23] = arguments[_key23]; + for (var _len24 = arguments.length, items = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) { + items[_key24] = arguments[_key24]; } return items.reduce(function (acc, item) { @@ -11584,8 +11622,8 @@ }, "(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"), // ------------------------------------------------------------------ list: doc(function list() { - for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) { - args[_key24] = arguments[_key24]; + for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { + args[_key25] = arguments[_key25]; } return args.reverse().reduce(function (list, item) { @@ -11601,8 +11639,8 @@ }, "(substring string start end)\n\n Function return part of the string starting at start ending with end."), // ------------------------------------------------------------------ concat: doc(function concat() { - for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) { - args[_key25] = arguments[_key25]; + for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) { + args[_key26] = arguments[_key26]; } args.forEach(function (arg, i) { @@ -11672,8 +11710,8 @@ }, "(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 (obj) { - for (var _len26 = arguments.length, args = new Array(_len26 > 1 ? _len26 - 1 : 0), _key26 = 1; _key26 < _len26; _key26++) { - args[_key26 - 1] = arguments[_key26]; + for (var _len27 = arguments.length, args = new Array(_len27 > 1 ? _len27 - 1 : 0), _key27 = 1; _key27 < _len27; _key27++) { + args[_key27 - 1] = arguments[_key27]; } var instance = construct(unbind(obj), toConsumableArray(args.map(function (x) { @@ -11793,8 +11831,8 @@ 'list->array': doc('list->array', toArray$1('list->array'), "(list->array list)\n\n Function convert LIPS list into JavaScript array."), // ------------------------------------------------------------------ apply: doc(function apply(fn) { - for (var _len27 = arguments.length, args = new Array(_len27 > 1 ? _len27 - 1 : 0), _key27 = 1; _key27 < _len27; _key27++) { - args[_key27 - 1] = arguments[_key27]; + for (var _len28 = arguments.length, args = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { + args[_key28 - 1] = arguments[_key28]; } typecheck('apply', fn, 'function', 1); @@ -11946,8 +11984,8 @@ typecheck('for-each', fn, 'function'); - for (var _len28 = arguments.length, lists = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { - lists[_key28 - 1] = arguments[_key28]; + for (var _len29 = arguments.length, lists = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { + lists[_key29 - 1] = arguments[_key29]; } lists.forEach(function (arg, i) { @@ -11966,8 +12004,8 @@ map: doc(function map(fn) { var _this19 = this; - for (var _len29 = arguments.length, lists = new Array(_len29 > 1 ? _len29 - 1 : 0), _key29 = 1; _key29 < _len29; _key29++) { - lists[_key29 - 1] = arguments[_key29]; + for (var _len30 = arguments.length, lists = new Array(_len30 > 1 ? _len30 - 1 : 0), _key30 = 1; _key30 < _len30; _key30++) { + lists[_key30 - 1] = arguments[_key30]; } typecheck('map', fn, 'function'); @@ -12039,8 +12077,8 @@ }, "(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"), // ------------------------------------------------------------------ fold: doc('fold', fold('fold', function (fold, fn, init) { - for (var _len30 = arguments.length, lists = new Array(_len30 > 3 ? _len30 - 3 : 0), _key30 = 3; _key30 < _len30; _key30++) { - lists[_key30 - 3] = arguments[_key30]; + for (var _len31 = arguments.length, lists = new Array(_len31 > 3 ? _len31 - 3 : 0), _key31 = 3; _key31 < _len31; _key31++) { + lists[_key31 - 3] = arguments[_key31]; } typecheck('fold', fn, 'function'); @@ -12065,8 +12103,8 @@ }), "(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"), // ------------------------------------------------------------------ pluck: doc(function pluck() { - for (var _len31 = arguments.length, keys = new Array(_len31), _key31 = 0; _key31 < _len31; _key31++) { - keys[_key31] = arguments[_key31]; + for (var _len32 = arguments.length, keys = new Array(_len32), _key32 = 0; _key32 < _len32; _key32++) { + keys[_key32] = arguments[_key32]; } return function (obj) { @@ -12079,9 +12117,9 @@ } else if (keys.length === 1) { var _keys3 = keys, _keys4 = slicedToArray(_keys3, 1), - _key32 = _keys4[0]; + _key33 = _keys4[0]; - return obj[_key32]; + return obj[_key33]; } var result = {}; @@ -12095,8 +12133,8 @@ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { var _this20 = this; - for (var _len32 = arguments.length, lists = new Array(_len32 > 3 ? _len32 - 3 : 0), _key33 = 3; _key33 < _len32; _key33++) { - lists[_key33 - 3] = arguments[_key33]; + for (var _len33 = arguments.length, lists = new Array(_len33 > 3 ? _len33 - 3 : 0), _key34 = 3; _key34 < _len33; _key34++) { + lists[_key34 - 3] = arguments[_key34]; } typecheck('reduce', fn, 'function'); @@ -12150,8 +12188,8 @@ // Numbers // ------------------------------------------------------------------ 'gcd': doc(function gcd() { - for (var _len33 = arguments.length, args = new Array(_len33), _key34 = 0; _key34 < _len33; _key34++) { - args[_key34] = arguments[_key34]; + for (var _len34 = arguments.length, args = new Array(_len34), _key35 = 0; _key35 < _len34; _key35++) { + args[_key35] = arguments[_key35]; } typecheck_args('lcm', args, 'number'); @@ -12161,8 +12199,8 @@ }, "(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."), // ------------------------------------------------------------------ 'lcm': doc(function lcm() { - for (var _len34 = arguments.length, args = new Array(_len34), _key35 = 0; _key35 < _len34; _key35++) { - args[_key35] = arguments[_key35]; + for (var _len35 = arguments.length, args = new Array(_len35), _key36 = 0; _key36 < _len35; _key36++) { + args[_key36] = arguments[_key36]; } typecheck_args('lcm', args, 'number'); // ref: https://rosettacode.org/wiki/Least_common_multiple#JavaScript @@ -12202,8 +12240,8 @@ }, 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 _len35 = arguments.length, args = new Array(_len35), _key36 = 0; _key36 < _len35; _key36++) { - args[_key36] = arguments[_key36]; + for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { + args[_key37] = arguments[_key37]; } if (args.length === 0) { @@ -12224,8 +12262,8 @@ }, "(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."), // ------------------------------------------------------------------ '/': doc('/', function () { - for (var _len36 = arguments.length, args = new Array(_len36), _key37 = 0; _key37 < _len36; _key37++) { - args[_key37] = arguments[_key37]; + for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { + args[_key38] = arguments[_key38]; } if (args.length === 0) { @@ -12291,8 +12329,8 @@ // ------------------------------------------------------------------ // Booleans '==': doc('==', function () { - for (var _len37 = arguments.length, args = new Array(_len37), _key38 = 0; _key38 < _len37; _key38++) { - args[_key38] = arguments[_key38]; + for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { + args[_key39] = arguments[_key39]; } typecheck_args('==', args, 'number'); @@ -12302,8 +12340,8 @@ }, "(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"), // ------------------------------------------------------------------ '>': doc('>', function () { - for (var _len38 = arguments.length, args = new Array(_len38), _key39 = 0; _key39 < _len38; _key39++) { - args[_key39] = arguments[_key39]; + for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { + args[_key40] = arguments[_key40]; } typecheck_args('>', args, 'number'); @@ -12313,8 +12351,8 @@ }, "(> x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically increasing"), // ------------------------------------------------------------------ '<': doc('<', function () { - for (var _len39 = arguments.length, args = new Array(_len39), _key40 = 0; _key40 < _len39; _key40++) { - args[_key40] = arguments[_key40]; + for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { + args[_key41] = arguments[_key41]; } typecheck_args('<', args, 'number'); @@ -12324,8 +12362,8 @@ }, "(< x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically decreasing"), // ------------------------------------------------------------------ '<=': doc(function () { - for (var _len40 = arguments.length, args = new Array(_len40), _key41 = 0; _key41 < _len40; _key41++) { - args[_key41] = arguments[_key41]; + for (var _len41 = arguments.length, args = new Array(_len41), _key42 = 0; _key42 < _len41; _key42++) { + args[_key42] = arguments[_key42]; } typecheck_args('<=', args, 'number'); @@ -12335,8 +12373,8 @@ }, "(<= x1 x2 ...)\n\n Function compare its numerical arguments and check if they are\n monotonically nonincreasing"), // ------------------------------------------------------------------ '>=': doc('>=', function () { - for (var _len41 = arguments.length, args = new Array(_len41), _key42 = 0; _key42 < _len41; _key42++) { - args[_key42] = arguments[_key42]; + for (var _len42 = arguments.length, args = new Array(_len42), _key43 = 0; _key43 < _len42; _key43++) { + args[_key43] = arguments[_key43]; } typecheck_args('>=', args, 'number'); @@ -12757,11 +12795,11 @@ for (var _i5 = 0, _Object$entries2 = Object.entries(mapping); _i5 < _Object$entries2.length; _i5++) { var _Object$entries2$_i = slicedToArray(_Object$entries2[_i5], 2), - _key43 = _Object$entries2$_i[0], + _key44 = _Object$entries2$_i[0], value = _Object$entries2$_i[1]; if (obj instanceof value) { - return _key43; + return _key44; } } @@ -13010,8 +13048,8 @@ args = args.map(function (arg) { if (is_lips_function(arg)) { var wrapper = function wrapper() { - for (var _len42 = arguments.length, args = new Array(_len42), _key44 = 0; _key44 < _len42; _key44++) { - args[_key44] = arguments[_key44]; + for (var _len43 = arguments.length, args = new Array(_len43), _key45 = 0; _key45 < _len43; _key45++) { + args[_key45] = arguments[_key45]; } return unpromise(arg.apply(this, args), unbox); @@ -13346,12 +13384,12 @@ }); var stack = new Stack(); - var _iterator8 = _createForOfIteratorHelper(tokens), - _step8; + var _iterator9 = _createForOfIteratorHelper(tokens), + _step9; try { - for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { - var token = _step8.value; + for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { + var token = _step9.value; if (open_tokens.includes(token)) { stack.push(token); @@ -13372,9 +13410,9 @@ } } } catch (err) { - _iterator8.e(err); + _iterator9.e(err); } finally { - _iterator8.f(); + _iterator9.f(); } return stack.is_empty(); @@ -13661,10 +13699,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sat, 06 Mar 2021 15:47:29 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 07 Mar 2021 12:25:17 +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('Sat, 06 Mar 2021 15:47:29 +0000').valueOf(); + var date = LString('Sun, 07 Mar 2021 12:25:17 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13704,7 +13742,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sat, 06 Mar 2021 15:47:29 +0000', + date: 'Sun, 07 Mar 2021 12:25:17 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 8dda4f88..9b6769e9 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sat, 06 Mar 2021 15:47:29 +0000 + * build: Sun, 07 Mar 2021 12:25:17 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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.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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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 s(e,r)===r.length;function s(t,n){function e(){return t[i]===Symbol["for"]("symbol")&&!is_symbol_string(n[u])}function r(){var e=t[i+1];var r=n[u+1];if(e!==undefined$1&&r!==undefined$1){return s([e],[r])}}var i=0;var a={};for(var u=0;u<n.length;++u){if(typeof t[i]==="undefined"){return u}if(t[i]instanceof Pattern){var o;if(["+","*"].includes(t[i].flag)){while(u<n.length){o=s(t[i].pattern,n.slice(u));if(o===-1){break}u+=o}u-=1;i++;continue}else if(t[i].flag==="?"){o=s(t[i].pattern,n.slice(u));if(o===-1){u-=2}else{i++}continue}}else if(t[i]instanceof RegExp){if(!n[u].match(t[i])){return-1}}else if(lips.LString.isString(t[i])){if(t[i].valueOf()!==n[u]){return-1}}else if(_typeof_1(t[i])==="symbol"){if(t[i]===Symbol["for"]("*")){a[i]=a[i]||0;if(["(","["].includes(n[u])){a[i]++}else if([")","]"].includes(n[u])){a[i]--}if(typeof t[i+1]!=="undefined"&&a[i]===0&&r()===-1||a[i]>0){continue}}else if(e()){return-1}}else if(t[i]instanceof Array){var c=s(t[i],n.slice(u));if(c===-1||c+u>n.length){return-1}u+=c-1;i++;continue}else{return-1}i++}if(t.length!==i){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(e,r){this.pattern=e;this.flag=r}Pattern.prototype.toString=function(){return"#<pattern(".concat(this.pattern," ").concat(this.flag,")>")};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=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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator7=_createForOfIteratorHelper(_keys),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var key=_step7.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sat, 06 Mar 2021 15:47:29 +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,") <https://lips.js.org>\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:"Sat, 06 Mar 2021 15:47:29 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 12:25:17 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 12:25:17 +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/src/lips.js b/src/lips.js index e2b8289f..88aadf0f 100644 --- a/src/lips.js +++ b/src/lips.js @@ -117,7 +117,7 @@ // ---------------------------------------------------------------------- /* istanbul ignore next */ function is_debug() { - return user_env.get('DEBUG', { throwError: false }); + return user_env && user_env.get('DEBUG', { throwError: false }); } if (!root.fetch) { /* istanbul ignore next */ @@ -1070,7 +1070,7 @@ // we don't want to check inside the token (e.g. strings) this._newline = i + 1; } - if (this._whitespace) { + if (this._whitespace && this._state === null) { this._next = i + 1; this._col = this._i - newline; return true; @@ -1668,6 +1668,15 @@ (!next_pattern || match(next_pattern, [input[i]])); } */ + function get_first_match(patterns, input) { + for (let p of patterns) { + const m = inner_match(p, input); + if (m !== -1) { + return m; + } + } + return -1; + } function not_symbol_match() { return pattern[p] === Symbol.for('symbol') && !is_symbol_string(input[i]); } @@ -1688,7 +1697,7 @@ var m; if (['+', '*'].includes(pattern[p].flag)) { while (i < input.length) { - m = inner_match(pattern[p].pattern, input.slice(i)); + m = get_first_match(pattern[p].patterns, input.slice(i)); if (m === -1) { break; } @@ -1698,7 +1707,7 @@ p++; continue; } else if (pattern[p].flag === '?') { - m = inner_match(pattern[p].pattern, input.slice(i)); + m = get_first_match(pattern[p].patterns, input.slice(i)); if (m === -1) { i -= 2; // if not found use same test on same input again } else { @@ -1908,23 +1917,28 @@ return string.match(this.pattern); }; // ---------------------------------------------------------------------- - function Pattern(pattern, flag) { - this.pattern = pattern; + // Pattern have any number of patterns that is match using OR operator + // pattern is in form of array with regular expressions + // ---------------------------------------------------------------------- + function Pattern(...args) { + var flag = args.pop(); + this.patterns = args; this.flag = flag; } - // TODO: make it print Pattern.prototype.toString = function() { - return `#<pattern(${this.pattern} ${this.flag})>`; + var patterns = this.patterns.map(x => toString(x)).join('|'); + return `#<pattern(${patterns} ${this.flag})>`; }; // ---------------------------------------------------------------------- Formatter.Pattern = Pattern; Formatter.Ahead = Ahead; - var p_o = /[[(]/; - var p_e = /[\])]/; + var p_o = /^[[(]$/; + var p_e = /^[\])]$/; var not_p = /[^()[\]]/; const not_close = new Ahead(/[^)\]]/); //const open = new Ahead(/[([]/); const glob = Symbol.for('*'); + const sexp_or_atom = new Pattern([p_o, glob, p_e], [not_p], '+'); const sexp = new Pattern([p_o, glob, p_e], '+'); const symbol = new Pattern([Symbol.for('symbol')], '?'); const symbols = new Pattern([Symbol.for('symbol')], '*'); @@ -1936,6 +1950,7 @@ var non_def = /^(?!.*\b(?:[()[\]]|define|let(?:\*|rec|-env|-syntax)?|lambda|syntax-rules)\b).*$/; /* eslint-enable */ var let_re = /^(?:#:)?(let(?:\*|rec|-env|-syntax)?)$/; + // match keyword if it's normal token or gensym (prefixed with #:) function keywords_re(...args) { return new RegExp(`^(?:#:)?(?:${args.join('|')})$`); } @@ -1943,8 +1958,8 @@ Formatter.rules = [ [[p_o, keywords_re('begin')], 1], [[p_o, let_re, symbol, p_o, let_value, p_e], 1], + [[p_o, let_re, symbol, sexp, sexp_or_atom], 0, not_close], //[[p_o, let_re, p_o, let_value], 1, not_close], - //s[[p_o, let_re, p_o, let_value, p_e, sexp], 0, not_close], [[p_o, keywords_re('define-syntax'), /.+/], 1], [[p_o, non_def, new Pattern([/[^()[\]]/], '+'), sexp], 1, not_close], [[p_o, sexp], 1, not_close], @@ -1960,13 +1975,16 @@ // ---------------------------------------------------------------------- Formatter.prototype.break = function() { var code = this.__code__.replace(/\n[ \t]*/g, '\n '); + // function that work when calling tokenize with meta data or not const token = t => { - if (t.token.match(string_re)) { + if (t.token.match(string_re) || t.token.match(re_re)) { return t.token; } else { return t.token.replace(/\s+/, ' '); } }; + // tokenize is part of the parser/lexer that split code into tokens and inclue + // meta data like number of column or line var tokens = tokenize(code, true).map(token).filter(t => t !== '\n'); const { rules } = Formatter; for (let i = 1; i < tokens.length; ++i) { @@ -1977,12 +1995,15 @@ var sexp = {}; rules.map(b => b[1]).forEach(count => { count = count.valueOf(); + // some patterns require to check what was before like + // if inside let binding if (count > 0 && !sexp[count]) { sexp[count] = previousSexp(sub, count); } }); for (let [pattern, count, ext] of rules) { count = count.valueOf(); + // 0 count mean ignore the previous S-Expression var test_sexp = count > 0 ? sexp[count] : sub; var m = match(pattern, test_sexp.filter(t => t.trim())); var next = tokens.slice(i).find(t => t.trim()); diff --git a/tests/formatter.scm b/tests/formatter.scm index 07a43b79..559dbb74 100644 --- a/tests/formatter.scm +++ b/tests/formatter.scm @@ -24,11 +24,19 @@ (print x)))) (t.snapshot (pretty-format '(let ((x)) + 10 + 20 + "xx + yy" (print x) (print x)))) (t.snapshot (pretty-format '(let ((bar (foo bar (baz))) (foo 10)) + 10 + 20 + "xx + yy" (foo bar) (print0)))) @@ -67,9 +75,9 @@ (test "formatter: define" (lambda (t) - (t.snapshot (pretty-format '(define (foo (x) (+ x x))))) + (t.snapshot (pretty-format '(define (foo x) (+ x x)))) - (t.snapshot (pretty-format '(define (foo (x) "xxx" (+ x x))))) + (t.snapshot (pretty-format '(define (foo x) "xxx" (+ x x)))) (t.snapshot (pretty-format '(define foo (lambda (x) (+ x x))))) @@ -77,6 +85,11 @@ (t.snapshot (pretty-format '(define foo (list 1 2 3)))) + (t.snapshot (pretty-format '(define (foo x) + "foo + bar" + (+ x x)))) + (t.snapshot (pretty-format '(define foo 10))))) diff --git a/tests/snapshots/test.js.md b/tests/snapshots/test.js.md index 0e39e1d3..7f7e7cbd 100644 --- a/tests/snapshots/test.js.md +++ b/tests/snapshots/test.js.md @@ -32,13 +32,14 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 - `(define (foo (x)␊ - (+ x x)))` + `(define (foo x)␊ + (+ x x))` > Snapshot 2 - `(define (foo (x)␊ - "xxx" (+ x x)))` + `(define (foo x)␊ + "xxx"␊ + (+ x x))` > Snapshot 3 @@ -57,6 +58,13 @@ Generated by [AVA](https://avajs.dev). > Snapshot 6 + `(define (foo x)␊ + "foo␊ + bar"␊ + (+ x x))` + +> Snapshot 7 + '(define foo 10)' ## formatter: define-syntax @@ -79,6 +87,10 @@ Generated by [AVA](https://avajs.dev). > Snapshot 2 `(let ((x))␊ + 10␊ + 20␊ + "xx␊ + yy"␊ (print x)␊ (print x))` @@ -86,6 +98,10 @@ Generated by [AVA](https://avajs.dev). `(let ((bar (foo bar (baz)))␊ (foo 10))␊ + 10␊ + 20␊ + "xx␊ + yy"␊ (foo bar)␊ (print0))` diff --git a/tests/snapshots/test.js.snap b/tests/snapshots/test.js.snap index fe03416e1f9e21c8564c2539d3304e72cde32743..e2c0151a966f10d805a36ee9bc52a6e39debd323 100644 GIT binary patch literal 18197 zcmV)IK)k;}RzV<BZeeh9Xm4~Nb}|YA0C*|ZGt7S2?{D6Fx9`q!@E?l^00000000B+ zoe8vOMRo3Pchk(!Ac#!DrJ1^ghI6XwRGkAfDD$8q;Dn&qBepi(*fiScixD$u5)_B{ zjLAx#8k1<ES>`#1D9^+gO?()l;!EQ2l4y)m921Sk_ulvW&TXO3!T-O#H)O517L6OL z?>%*@PSvhGe0%TWmlw^<>^HOZsGok<*FSUFhkx+WZ#?0}-TM#L5B2AbqO-Rge(`Vo z`Ql}V?Dxr!Kl5d8J!+AE`c2X1#amza>3x4I9<}M+>wkCsb<39erzbAz>4rJ_<Q%P9 z+|$QI-@WemUwQQP*Z%EWKKlN6#p~~R&tm`dSxb8QfoPA}%U=GFmmOI>|Ga<y<~0}p z)uns+r^oNn(^Yfy@;UmuIof+^Pv^|hwW4L8{6AN97d~zK<7aNa^PW>)zSk1}^c8b- z&m67Zb7to0-7`P&YoGkLMIXLvN!YyCQGc|^KfO)#lHdBo8=v#(51sS!)!pqM*#B|= zu*g4sr|6KoPx_s2-?ia+&;9;ewqN@9NB+WM|MY`%bk<EXGjBNJh1Z{T(kaJnyy>(% zF8ugeUtHv$zFG9CJI}iO?t5ObWAO#2Ui|6HFMZ`A|Mb`1H#4(jW-qV*qNOtjFMjpR zip?9g&#qXpW45kVuH1KacEzTRvn!srVcXVoW_R#+{;XKL;rdNm=Ki9;uHSUijholp zGP|7Tman|`7h5(wck`w#8&*#3xMl11*&o|^<;wfcanU)R;->8zwvFb=YkoA@9}U_+ zx@uO>j$U@s=zDM6wrR`u{#$?4-nGveJNvjpUFlzee=Xm!gCTFZW%=&C=P7gVS-VEl z+qiY>tQ%|BJa6T_bLYo%Gy8D^&Go!@plUGArT31r%X=AW_SrYzyyJd{oBH0xuiD8h zbG>%HWXFyjbK7zA=FR8KZrgCv_ItN==kBh%dE2%PTeh#-wB^Q|x39W!>$dxQM(g3; z_hBIYNW<;s3|~64V%^p)>qk?(?`(H2#kN_m{LUu^ta=|_-Eki#9kY1<!uzoC&Pfh9 zZ}F|WIk)-G=*PU~-U;o(B}cAUzhR^L^$+xXdy3A?kZYHZpA$dsSpMUlKYi!(Ugyng zZdkj1jd*0Z+dKR2+WEZQ>%4OU(_eVRt}onl)AreVHq6GsV=M3HBh_LEE!~g()@Ap7 zyY_LHU!J_;rdzgbU$bM?wwpI^xM_BUS9ryBb7Hlh%V@sk{yX(uHf>zFTQ9kK@RHT5 z&)(T@&8+@1yLPVkV0~Atfj`gEhpxHrimy0ZKUuqSBugJP_w}p#(PsMvyPprZ@09O5 z>0MuU)QT1T*6cewY~1_c9@1aem0b?jrp-;=rn;@GT&1>ZOYUOVR!v)Xr7J0v5^~oz zxvA@_YGU2Rtj9~KatSflb(5N|Nuf(czs$MHbz7Py=M<ZiN)EZSsSR~gf_@u{dbTlz zRE4Um_3zl|1v%!bG+oZQ4qa1MdReSu)5X+Ot;VZT7u61(CQ#a{Xilx(kwS<m>ghJ; zwy9FkOHxyEokOQVb5~+l<yeKbsw=&u(HAnj-k?|4`l=WU{|ow{N^{Juep{7XHFeSl zw_Tf4mzz{lrvam0qWNj0tVL?uq@TntwwhMeG)%LpH0PMR5QAP@>7(^WYorCz0>@5& z?>en$r$^e5N~eV>Rnmtv*)z>rNG(L;b!_;^y2Q40DTa>qh+WEU-3Gl|-&|s9HDf)R z_2GKIHm}xamXg{|>l5psb>vst675*gmW84b^j%t_y3+17T8ggXJDSpJ!ZB-6LsMrh zxZc)kEyNh&j!yHbwalRrGiaIWp!ICBW{|}PTBtUas_SaaTmNoTRi(O$tVGs+dndH_ zT4ZghSW1mrlhOOM%2gG#AliSih!##0(UNP#I%;XMrZ2{ce7N>si&JZdqBt?P8oaHu z*rf|~is~#T)#5gOQ)Y%*!q`N=E{S0~v2PK7cA?UyvA0zS;yE#D)wY$Gtkl{faSETR z$=2*_uJvNInxKW%7K+!~l9+{Fp7g~vTd(;w`d%%AzOiTrS}{-H51&!gKSh{NCrgJ( zJKM$>S^7?U#I*HlO`_EqQJ+@FL`O=Cq8GE}uvrW`Hf*w(U0o83p-t8V#r{QGsKsjZ z$!tW_8)}gjLLVCRy4YyPHI_bBlWX+9M$Dy^OIk7={?zia#7WdlTl#kToqkZ&dSB8S zz%rV$SgX^PNnU8_D(zhiS`dkYl=ThTlfp;ngw)zjF|o$cgG@}^lv8S8<`Qc$pN1;2 zXsfCSPnMu#qj}^~>!n3!Oy9(j={jv=lY^E-+@r~h&-944Q#%*ctl&c!ENGj=gIX*x zx{gE>*=(KXq&3nZ>nd$}$M<IOn$CTzz0yzhPI00>R$me;<d4on%KF^KTNbtQVzdZL zO0MaY6u1n|(GzXfT8f{w3rWXKi(A8z;+M9FuY%@;9FiC+nq3_tEiI%ah}cdX)pwWF z)&8+z+3VbJ%=HS*S&ONUY>^?_BAq7v0-+(U4se9Tlun4|CE*lx{%ZX|qP0Ryi)pgu zlLTX^JFkg$RnkXWE2fpW*D(|WG#$$?-jxWh^m=WAzCoWKeMW+gt+u_@lv@ehQX|?V z%`_v4aXq88(!0cVZIFPKB+&wDQMHreHO;-~cbz0>BPR9~qh78hY+JZdeI<HZAJ|Ib zPJK0=WmCs#t2o7+v_^X-0l~WJV2EFIzz`#)YCFD}70(=4>l4jQGOuA`0X+r_iaVsC zB&EcHl6L_~-es6rXIVU~o!0tjN>M-Qq|?NKHL@xu_)Ovljb+^^Zqn4msc?aIgZW7a z=$%q>;y@i1JzQzx8dTax%w14I(vC?|rL)LsrQ5R9feuI&bTq~2+OkF*6p}=Qei`Yi z*=j}fr5ceRRVV;GnJwIs)=YEeEG6~UYG_WizEZkRU#L0g<Jfv}PvPWg@6iC_6ln~t zUS?fUUo1f9pP)^OIHM{E70Fx8R=gNE1qq21c_FL7wu|w!P6b_MW)`m$*gGLuWl`wx z=m+`^G>i{e)5~`)X@!L#9U=}Bw~ND3#mulqVltvQsbMBs<t79qDgs!KYN8b^sO^AP zqyn{{G5Dx!0Rv|+GFpZGAeDyJLjg&~OA1KPO2}vxGWyqBD7k=<prfOQB`PGl3O%HE zH6oMOhH4G;B@z(QX&L<}WtGq^T9_gY613!cUqX<H+4N;P7J6qwXKRlnQPA)xy^0Og zoV?4@;remHtl)*>T(O2WK?^RqC>g9VB=+<%I^5DJ4W^WqTIZswu_yFG?Vu!Y=VOj8 z($E~GVkVMG*TQLqB$N=El9~-W*KsnW&uT=c*g|5c;>@rn2{oQD8Ujm>^-*(VBrwEz zlH6#jh;-6~w43?|`ORt4-f-fxITsx%Hqm*~>&0o3f|xQjCXB?3_NvuqL>*sky%<n( zMa!yh30h>aM<uDP3D&7Wgo?S;lhv>=Y+;*5i?1)#$(7KrTA8q@r>5UDZ70SpQX8AB z#*Qdbr7awdfI?ttGi%I3bWM_4l-`Z#Eq)>Usev!i5E+w7eAvLl5?0#AA|a|{fK?#f zFCNjmLxqfOG(njhm~PV4HN0N482Xypc9YmYB0t4uG8@^tMArZpW8iXFn3Z@@TTl?V zDJBea1i5%4uts_w6H3eg4`Wke?P-I>-qQS1rxIYAvbeLrznOJKBZ(VYj+o}6b0(|K zzJRo0LUijp^<^k8u`cpW&q}&sza$hf%nAF*2p22pYjxlPN|OVYn3;89g*%`{;B;ZP zODstKO8SWhu=BMB;#0WY;sjTN&xPgTNlja8UwR=alcM23M2=IzCBVcNJ7Mm__p&09 z#<kc%Ka~N4`50_!NI1%Xl_b=rFk5|-Hbq91)l9_H)!{<=OD<%zAyx)zLR=??w&5V* ztN!{B=@D(QO*G9~;z(`%2tnVe6B0l7np(?)w2*|?+977dz%o>10BU8BBHB)w_2R$6 z!X|7dO{1Z+#t&LJcE4sfwMJTmfK-=k)^g}jBhh*{p@M0}Kekr1P*xVwDiMdI!Mx*x zG3_K1BYGb0Oco*HyarQLzmxRHl~p}vj`*i#I(RV!UeNq85YQ?5rL0<gXl%Ta+IB6j zzFqcAK@M8YW~2`O35HjT$bvN^Hj0eVs`roB$;dy_Au`Zq88(<+Vssx1Y<-<oxY%0V zV!Gzn*pf0X(J?KCdx3RY37rDx>$qzKEL|T`8K+`g9i0v<qQiJ7NLdNR8b30^)QO`m zT`l1z8%5^@(?Y++W$KW$GOAm=jDV4e{U-jEI<^IaeD{YI4x9E*=P=>T!Xr`>wOyYI zlUcu(>4$%<Et5jRan2b25nD>fr9ybB0}2C)tUZ*GF6E-vViAh<@LD^bkOhkPsqCBt zY$N#}l^0V&mE(@p!s!fkZzM<oC-k=D5^prSX{R+OeXSN>rl5|ict>I^qcNrOTe*V) zX^QnDo)w$aXlvYC4wjCq>?_$JQpdPc;+M=xZG1p0)DaE<_&}otMxq7m7qdal8PWLS zPl;%;q1Hl&7!?e-(BUUaRmcEgZ?r99CNYOrPivzQjACdV^g``Qg-5Do@8u*+AqGJ} z;jSPCDjY0vqqJ#-r>G|oG64%rr=vn)V9DwYvURY2ag;jTbDe^aIsa0+vUpp>s}3rR z+}c>sipkm6)Kck>rNpZaEoK7R5t-lE^o*#OXpx8&8$kjh!nnnIlLe0fij|zL`ZYYS zXgIv`Xk=#M6<R_S3{{N;4uSV14y-W0u|y@DSS_@xw7QxZ?>(W8YZ$f$FNlB;k_h-@ zniapt_}0X0Fa#}GizC6oG%genB+{`JItOD(5|?uy(BE2AoFKRXCqo)oi;^rw)B~g- zqxK~~#33+x;AkNSwE}uDpfGIc0_|vl3rx%b<z$Ih6MGfyMC&_nRek35tva@aZ`L3g zHLgRz&UZdH3D+G&2tMea*G>kEpp3zgIRXK_W4uUeMhh$XgF8{|U~1xc7BUhgp<5I- zNLdEBY5<KIqyfN`Rt(ce$3YB^87P@;nTDdqF129o@bYvdBt)?KjFhx|i;fDuinzyK zvp%!I+llt3u?aPIK$(CwCytK@=MLG16NKJ~=zA=8@tW9HhEZb!AB#<zm+qJ`nx5XN ziRl#T?1*2)@K}jjXk#|OZCD_<r;_sQJ3c_syHOF?6Jk_J8lO`sPHaOClIE`kYd}b} zkNPZ~`ozj>%@YtvL5gC+Vq{hb6mg%-B1wFiKov?FMPs#ze&s1X))18TU&jgsDh8G* zQGsn0yjyJ@_F=(aLh@qFW;|J~x-3Oa8s8WTr@~W%c|cj@EOe-h#wKhqhf0nme8B`D z5TpZg!9oW-)d5AHz{(i2fJ80mi3BY!k8~gAj5t>xT(f~Xx46jKb7rjfNVe6s>7&6k z&QHx})bN6KnO(p{mYmccXV5TNFq(Y8P?p~3(4rtS*ry~QAOgo9Eeno>?$%f6EMx3p za7wlyHF!6u96P2tAY}EDQX4WtmfGZLFb4oaFqU|^js)sM)`)C!IgUE>hB`U)HAbz( zxJ@q2r}8$iss<4xMzQ6!nh~!_Bj`CcAR8=Z20EfB4!EO1^hNeoys4#6EGkeA3R&X3 z1(J}Y1E1}+E3k^$r5F{H{KFYz0RyIBW@9A)WCUpY1F)fV3HSvDlkrb|ZH4sFs#)Pl zXmH@fkeaECVmu6W)V6VaK?U_kKk4xFr9-vGI5`!b0XDMUBtZ^fAc0qaI%=~lAe|P7 zBLor{(R4L-iO#Dw01pLwr-MtSc9K7{2DE6gYs5+Jfk`VxoUsCd%C-D+ScMLgbe4XA z<y3nA0c(iuZg>o!K_k}4B3N1f5`$@3(GGm4HY(vVqG@X2r5Ko^{8>!`bh^UZ!E7ns zNR4Db1U(V${{nyW4?7_~X>Et`oSa<jT&xzrdE2^rRg24ncttZJ>cjy2SR7Czc>^6e z=WGvLt3A%}h(t#V(j;>WK&QaZ;xWBi3}E4mYXagRp^o9Ie+BSkY!^JZ##nD<-~p3I z2SJJlfD7MVn<xHj5imM`>Wk%qK?}-&@Q}dNk`mOwR5d=pbD#zlavQ6tMup)B7^nn2 z!x{p~*J}WZ#H^aNev7aKLbN|F-UR|;*%ILy$u2Bk9Y<_V6q`P_BF-Vc*Uk{RkgbcF z>Ci5i4IPjXYTT|P_Am<te}g>P-@t(Yc9Ijsq0$!^7)Tg5fZe&Zp(=L6^wBBAAJZDt z_8zgG5<AmjNcNt#YzB!98TH7l4DVn*wBXK()2eT3G0`w#Y!Sof;4(EqhZ>j_+&f^M zXN<-gD@mG0OWYtwz@Zxe=0u1_6BQ2t@0B@)i1tCp;E7_67o;mzh}Qz8o^ZD!*hs)E zXz{GN)~m>ICUR84-kPZ-6GmZ1@ia)Ffa@%Ah12D50}g>Lxy%93Nlripz$`##xa`I- zweI4=3ZDsQlNb=TGhVei8LOy>A0cgk^Ta>6BQ~ZHuu`zH8Z>f^nJ(_rsPZuzgX8Q( zbX=p+=vaahWw<KDR*36$Xka6Hs3&bPj=ZtjV4R+F9MR-BjKC-zDmdbu14?K{z;)pI zpezY&QRkw7IP}myx-N075~2*5TC6B=UV_=&I#P$b#@@u<lhe?`K!jIh+F|82+OCX^ zE(wbfOmGKdRPs&&A%Fu(pwvFyQq|&KS-@z^ijG>}L>Lgh0C+$w5pg0=Wz?Nn!q#X* zkg1N48;6ka3&N7a4W9;w4vGyCaE=<YF9Y(L6WIs+>&7^wO=EF;1N?`2Y0-BzK9Tko zSB`=3i#dnbtqssyz-t55@9=^GR()+S5I?uVZA0xf2$bAAz?ESX9|B+-1W6<g)4wVa z;Q)kl3?#A>@<D8|;I<mNE6Cso#;LCYc)?2sct+D}`fckFBKuka<tMCbJUEOpouy>0 zoN8m>5kVX<gMhs|yYj$TnshLnAWi|Mte9qHMBV`$tz3tF0^@YH8Y==La0wuhJSyBV zLcWA55+Ye_*WoA>f}D(lU5~Lv<V@_MK{J?i!E42*g6Rp!=)gDlXutr3Uomos6ckoT zte7#>0=PX;h7Pt^yLLbgQKWSPB`&~<25l>XIt{)HMt^O+mU?JivY2ooyaF&L<_CA? zkXAUXM0=}Zp#b(EfyoI29q51<<Th5G2pnP1pu$wws?~%MA`XlsUqLK_$pb&s=n60b zqD2*!Wxx+WT@%z0e<P9_Pzm%`!aL5<U_x{d0ep}*N>+mpYk4tk0-jL?00zGl{{_QV zpN4&-57StVh~cbtxUq=fK-2*lt#3`ywjjt9G8ynm?@cUFZ9}2$p}Wqq8%Re&Q9qAZ zO11r03^(Z$!tr?y!XbuH!xM?%u-FUD4KH-y>$0P9ubE9SP$vNpF((0CK?FKOH-s4j zRxb-ARyXhntWs45M{r(?UyPa};)KHzdtZp4gVrHovl<rATTo7&y&^)&nRpf<ba5F* zKp|Zs8(s#-)LwT6W3<qYrPKt)JG^dyYEA=6h?9(>!h9@!jM@NqBK+fEBNjx1TWFsv z5IiUDOHc@hJpw>BVA<9>z=7C^9TKYxhT5@4Y9ntAkztVaf?g#Izyy$f1dp1=SV(ZT z10E&;Of3{PFaHY|3?2McVP|M>aBT{aMa(j^4G9$uW-T5PLW>Ln9RR&X3*lrBLgC^+ z&KI5{q4?rB1O9Ohw2YUlcN3x{Dv$^r)a*vbmx)Iu4+<Yf-bw~&KxAj)pE^?wAy!Sa z?hLy21{c;?&Bk(|BU{!PQ%g8v8dGZv?w$<v5h!T!B>V9Y7>OtZkLn#A(S1!42OSL} zNr=5KAyBiz1|ShRpxSV$gt$(*;aQ@Xa`5;TaVJnR&ufo^F`0%ChqMUFDpd}yB`j|u z`JvZ;L{R`oBUY+p9#($`;*VL5qG$}0U_`T(2tCIM2v!jB20_8>C%%s%fh~=v5$FDg zci{XE#Ew%9kWPR>nD4bgJg_E`fOI4XUt(%hWMy>bY>5vrDj2G@_Q5(OdWPqOY9WQ7 zfItC6XsJmbN<dzbbph=p;FI9e+&Ex~bk1lO1HbtBhX05mM>{rHLtsh?bC15UH;X~j zlhvTs4yh<bMYNiP2;vf8etc$eh7Hy_fn=aW!V(TbN<tBm2U^fMCgX<iP6L`Db2i%F zA}-3VVd8b@9@eEpB1H0v2#edC$!O=y21&LxcFqWIA-1(Uh+5bkYd?@65?C~>C#-iE z2d@M#y^oIC`_0(QU_`R|IJhMFAl^FU7{(Sc8!|I83KicT>DAzp=-BE19UPHC8n8GB zSAbe%Ox?P3szKXZTYyL;MiHzhp$NkeC^FQBW<XvolSxp)Vk4q}cq>GZfI68-a+o8M zWx$r`3mXGZ*e#l7HkOzj*I|4O0(1srqvt_-0h(*vM@%guc35*HxnOK!0}+UXN3dPQ zP62ifB$?n4>L@gXPch)|*$AkTR$y<{Q3~94ve7_NGhB&n2w)`@tQ|sGbXXi5zgStH z;=_a<Gq4lyWUdxhFLIEG5_Uw)F{!YL^yy+6P9^vn@?V>bpFwEGGP$$S)U-y$oPr0; zpR>I^CnSi|v9S{;I2zhQqS_7B<O%Lo#;MpzT!w<>fqv~s;ONL>!6N{}Z_(WmNV^6Q z41}F!4axujcW|Z|n2jM%5Fl-DMB6zIDn9CPDR7BdPefsb8>78Ld}n9VF*^P?`VZ6B z_9q~@LqZY#M8u91n82y#P$Gr!&=ZQM0})JibR!mzp>xb3Vt3fi2opz-8xEj2QTvR+ zLWUM`y2SYt;{a)4Wk=E%v5?5MvaWKzo%I$tHG2n0OPmYY3<RjY=uYPpk-~+pBRL6> z2~;wHH8dE5Irjmo){?CueX>Jk2N<Tqj|?0hatR~xK^Zxj$TFEi*m$J=;6yl5444MY z3eG?{8)02JB@szNj2grVFp(HVLb_ntU{z+P=V`OE9XDh2m>(JGPtp|0Aiy?QcE;OL z4dgmBPI(|g<$yc~iU3LNfD3VmfSrbPs)*3^j+l;kLZ*`k1ip)TC!4=<<c*1wf<-c6 z#)h}N!B*6<C9w{00-+C*h7>1@hD0B%D3UI5MZjq=^T|cSIVWWyJIjJ7K;uOR)5eC% zy>0>72xMA;Zr7*|d^e)2WOnEwFzps?2v6Zo_JW$Thfa&|Em<F&Ex>6YfkdJMz&w~| z1AdDyE1ldDdC+#-Wg~iw)^aM6Q;<j+%y>IV>~F>F%r}f$sSJ|-NTrb_gZR_~*zY<M zW;h_Oge<Mekp!~EgajuAv?Vs$@-vPj@nihy7CqgP{!rO#2Pv<OMMbg@@GmhWL3Rmg zX6K8L#ekba&`cBQP^IK6Rl&KD_<e+I!EPhqqC`bSQi;R_zK<T(&zzY{bO1{aN!B`& zt3S9|Qmqx<02zdY@}={@Vo07d)Tt9+3_Byc!KlfTB(1>a`<&-N>L4Z&ei_go(aG4y z&+5)*V28&ToOZ$R*cN0yN~fS4obFH)abhhTr~rb)(jx__!{X7=%N#Q`#0I#tHHl!H zMXh>;S|amG5+~u)qU;e9QWQuj5?~tAe}cpOp>iUW4RvQfka?<eM@$o+CBmMDnhX^L zXH7)pFCkytU}Cqn!mNDyLyH$j_^C69T=)_4U9%#U*LEqeCeamABO8aEFl)d%B6tSM zN-TtFMqaSo5ga1TPc~W?3{Yb!;sUZ4<V;~-A>&9lYYBXkb-=>td*C8G``j5$t8lfm zqfA7p5p$AOMB$Jgpqs6;M~$valxsGGeG5PbX<)(VS#CUCtoPOtcc=c5Ox}=xiQzzA zseR%OmhA{xkgwc1EgZ`bIJOX0Km-DAVmSf8;<}JAkujD?au?s|pAJhI+{D5go<<8| za#wgCq?d`?E$CX{R3mewHaLiE=%#?of#HIciJ5D|u3~PVekbkW=2uRoC9^J;9{H9@ zh(pWQX*F0k>v%B=yNYM!xI0*zKP~_j=}Q3O2{|_8LNgJ3WsDdyupOJko&|9v*$ZqA z3>|~h{vwthmJ(4mJ1XRvHBP%E{9GC*3^>m=U_f9>R3Nt~3IJPRLGrpJRg3dx>=4tJ ztd15HL^6q9-a1i<ls~D4#wn5-i8xY=Jqny*yu7jbld}`)3ZZ_^qK{B?LL1f((H}mc zbp{=Ieg;ds-0u)DAIJk~)gA6NaW#Y^NJXDcNQN|-Q5^_ai$91p9<YV9$UX`LsR(D2 z;nk3l*Ele*H#i%SWy2~J(?-w)#~X_QH%*8<%f=BRWSwR}T5s@v7UW*39gJ|4BO81J zM=k~!!7v+&Akf*IE6FNSIsnm0x+j9?(hJxXb<{+2IH)Jd<0M#+Aksu9;9F=>umFVK zry3B5Xu@0~FfdWJd~6A6RO|{FTgVSFtUkvOCNTkg+m^kRHP$$l6`|EwWn)Aa;C0F& zI7?tkxCE6eNgPZ|xP+a}St<$|z@Pwh14Ik5NQzi;ULskQHG-fs#*SxV%n!UCM2f67 z>NfONLNFXsR1?J>#drz_9y=7PG+}IzL|*k0J>o^nLgzf7#+%xZMhuQbfW|sEA^A55 z5;6xsoiX)s*HIbh#cWu=Ml}PW$RgB6B|F8WFl4gEw7rtL93OF*IKwgtPo?tSfC-Si zT`aCir0L-HgkONsPt=lcBCU*kHwVhJ09CMF?)X+>tgMg`oP^%R;UR5}V2yrE4h`Qx zc4)^Jg0tEV##sfG$&C}VSsF})jA7e4-;f+>q6M~|Tr9&XXG{a_OCUiU=!0}O9F{^j zsE}GwI~0$F=HxQqq>ktxCWUhv_?E&%YNzRBCyT*8plRMn2Q4~my_Uox)Jvecr}4xC zn652$7g=OtO~m;)2S9#~bCKPaKtrkT05->NCax<@7hQkDnT^g%;M`a!kUvC9TB@A? zMM#F+s!W`Z1PrHR%%!XlCgkfd3mSVzFh1*yP(;+?l|(!<^5AekyFO;$QsG1RgVb9v zUETtO741aH+NtgKIW^T=2yBX$)@oz?w@A0x8yVnatwW^P%N-Gi;KfChWQS%ttRFs~ zT9^oU+ZahmwF4qnqhw=H6@@Nn{dYUes6?G#B1w4I;$efEm61gbbioM5y+ShLMgdWh zfQ4_#nRk{QDhw>Arv5Bh-AOl5MPehP!3qPxBijjZ4+T+-pcMkS6g;tL_|qgO5Zy(s za#(S~2wkFw#0I2oQ8`73y@K_D{~QM(S=$0B;>#8*5KLDcY4V*CdW&5Ir9khs*#G(# zu(af97JnqL3dyFxUiR^gC%DEUV;bRUMI)&sEs#b|44-Iq&Ffr|BldBmT%&>n01S~_ zW!V*srW2M0b0L|L45w_E0SpGem>gAdmPp$%bQ+zbX?Pd>2USj$5-F)YBuVuHkP)FW zpDz#~!t;)=N?hQPQ47~P>m#|M&Dz;+RfX|KsF&>e+HYr%P*vDa**XW*h8z{#a1zL< z0wQaocq3X=d`-?;(Wyhm^%@F4q_~~|Jxm&3LPuuIY}OL{5qB0`oFI~IE5d&q%7&aZ z@;{5sLf}24L5`<jhM^D$S>Y;j5E_D!0SQht#+iY{+lZVXa2#`p&acA{t2`6nP2$RZ zw5Igo5j<%8P!cx@fo9-&C)w1kaT-{VwIJHz{R}oqc^Dh5!pa3GDQNr%KuaA>pBSEe zVlZt8jx<hL1jTSsBZv~?k<~{nVdIz`I@ji(p#mp96wKO0tpd^ooJ~5_IkP0=_+!AR zons0Zg8Hwpw_s^;6*111Fl0r^7764)L}cU<N45(?dLv#Zu7D&Ip?l4TnUcy#LKr(n zjx<>Tn8WB%5*YEFalpZluwPqTq?)85Y8{AnkXcN27aE2nAQzahG}t4gj-$*Rqw1X6 zMEt5l;xbhrKd0enOjjs$RPNRI86D^^HaQ~O0R-?9;<uy^1&S8{K+)OaH(U%*RiZ+G zTC$BmBpfaU2O-rzgM)*~CMO>d-R^K8#Qr2Jx?nRIm?23X`6q4wkA-td2xJfdX6N4Z z<&X|;hUlU~>TE*XnaxDWA2AM!HAzKfn~>@hzu_)%SR8yN4H;A-l30yL?Lb9q&H#Ip z7Qy@^l+e1|2G6$&eL@4F*2oLU>j}Z-e}*f`^+Ar4Xj1G|Cr28Iq16r-;Z=0bw#wL9 zNM00l_V0kAorKXu8%TgxElEb08x*z%0CJ2ppibcOV$&Vj<QO6`ikd<r1bOA6X50vv zt-~v;C{b!$u7njzxPZJo6f%ZUYgZPF8o>@ILB<uvmHl>{vgp#p8pR?#iHqj631ZU3 z(_Cpr_+5-iPG((uucA>k02Ua690`}a67wS5QjiY*A=v>Wr#Nev{A_@s)*>04$a!MK zi|M1&o2i?yHwSMK=m05oQHQ>kK?7-%q#R+&MM}$B3M<IwqyS1hLDdEYkl?k}I`9H! zQs*Kd77fNUP7nM=o<HI`W|z7;trK>nxJqVIpIJlJ21!%deu?a4qb`&XhCWjl*^+}b zH}z}sDBwCPB?1JMRkgvIx{s+7@<SUpaCRa9Nof(8I<A9YRd7xT34(hi=8dn`I3o#T z#mQiu^NoP_FbqhrZ<r+fD1|`IY3@T#Mms2wtek>P5ChwV%*jyqB_yHG{EmHbTO=oe z-K5;Lb7ChrIhE9gMX3v-fPxf9a%)MF2b)P8Z4^KLb`u=!)8-R&@W?>qKHz=X4;fDh z7y|Qwm@w7E$QDqaiu_Zc^hho(xs$EEPc_8=lywqo?UVboF2M<$6sqaPm5XKd!7hEL zT&a+zgNg#!^wA)3y^!re?29_1+CDNVn9hR-Tco5UxdbcojfBlAk_t*6%jlfF0a#3Q z9q^u*wr!1ovjpVaP{|Ks*BOT<``AgviS!yGnznT?@$d&obgNyI=LAlJqttiQpm1bo z!Ss~EG$3<iZAb|_mjlcO90mW9${290J`y15$3g4*^ePl|=Mpwx8l3ey^!2>x%!)7s z=3i$wn$;lY(>TN)v27e2BhJT;kOPNf0HlYa&1Rw2A!i#aEI~{9Z*c-MhlH~YekI$( zrKQADSZpB62+)&U8Z3+1l}kj~gLj4$qzaWTtwJ(CK?#gW?h_z)3EhQgWoNM>2%Ldd z71w34ZscE7z;YBsVKkN6>GU-)GUcr;dO3SvU6NQR?rdz4)xdU6U`&q9IFrcuGHd}- z$z=vk9E%1sk(OjFx2^%f7;=)j>sp+`55VK_G>MZ0yL`&~$aCZG2ZbcL9-ub#c)g3z zNreGzrbfbv&V)?~JMa^NSBO?4Hj(tMLNzaN2heE?EKHgw&}zdy0=&nbrL(_Dat6F1 zFNJ&-oIiY3@*zRBsm;UNAl_i80=vao2C^~9l5zPYW#Xi`0i00?W4jad2?GJCOa2K# z3-|&PCHnpbybs_>TaR{38mf9L7f@12(ZD+dr#pnL)8rCvdYMBJ2@E-vp8?DqPQOPD zkWwP{tg#`f9&mt_ut)8}Cis%WL0~r#B_cHjca5r#KAyrlw}u$BT$H0yc83d4@VZ<c z3mBqfYb2|7YHm$HjJ)Vf0Gk>XY_YzK0^i=XPc}73OktrNPaqya!WoXbc8YXNPG`#g zSoAWHJ=|JMUrsElw69;y4tf)cXyHVhs_Xzr<ph=NnuKT=r6Y$O_roa<rJW1?QMzVb z;CoO4XN>w#j3BZyWN?#+M8vk^)KK3<5DUb|Cy4`!6eq`<j5x}7(E-?<fDDcA2B@5Z z?__c^23o_ai2mA^qi?lv8Z;poBprN(;wEpqU?ftB0J_Hg98`3mEV21f(tJ8;&(T&E zh3aJFRDHmji&bnwv0A=xgObobwHUXWEhV|YFgj^J5`C@lXvAAr4B_GPa<Hj_bbcHq z>~$ec#J9PCic*INs8>6)-6e)-Q))9f{T$oME(?_p#7n7*u<#)T5on0`Cs7)N9g%9# zFwAh@oPp}KYmkxI=tVLgEa(7nT!4^4y-3O9@R9H6T3-Sx2Dx#~i0k3XlEMYN$h@3( zlYJqB(<yLrxp2g++f^>QBUVqW5AW3MP4%w+N`xudqpP?n13jPdNm}C<#eg+nip>}l zdE3`-;x0(&6D>lk8XDzt2P)HDR*l{wBO0#?`CB=+z_-wFw?cF=JVpRn1*BvUKmn*A zzc>MVlh2Wyt1V}P*kX-pqbfien7e*zJ5t4Km)Xq9>D6Qe;#GxYAQJ_c`pZlz_bd*X z+N&+#FGfqqnE@fdGhhcmR;uC~QOL?pE;Qk;7|K^L<6`Z6Yp0*%exv>QTg5(u>ETf0 zv*8hwf6?LQ0ju*u5NLAssCbOdX-DazOEKXRFfZAllqPc}1Q4tNQ_dNcV#&THyFq4B z2QxRsWvL&)Rj#d2F{HTHfF*NOhg!}GUw}zcfx{W>if>1%4VK`fzz6CXNWjPX?Cbn+ zC7r`oTpa7vO@d`4u6HOUvL}dH1m{nqJ1|CFTY#5_*+uRz=f}Bxq%-3bkdZ{1l@naZ zYb3Fc5+oeI$`}l1(-=5etxldJGob5{Q_7Y33fsTT$r*vJWvF6b;MVl@R-{r@VCGn0 z+}h$&9;_e!P}M_0A~^<Rab(ISak`TQdtZmqa#aiUdf-?_gsE0`CN<`S%NB5?06p!g zkSB<qDFoH15C-%jyb=vdfT(cY6N;Ui0dQu(2Z=qBA4g$SHWW-e8Xvf^#%BiP*pk~! z5W#6KoO9ssV7QowE4Cm(H#;c4WP{u(jA~#2ZGaAS;rsz8QS+UwqkMfzagZG6j4W&y zi&8X_`y^C?4z2*m-gK%mNGL!8MAvtbzW~B$te=RhO~mA4C-@)}X&|2l$Bf{v#D&Wp zxXT7rhw0pV*MYg%p3&*@tsK6_hZqS3cG*chSmc!p!pKqPfRRiFQrS53fWVrRJWjr2 zkyQNy*)V&A3@{?n+GsFER{&l_c95S`vcksM_cTz5-nvW?tylN;xx^<~C#KG0CAypp zzzrcowlERs#CnpBL&+GmN2CB!SB191U(xoE2+b-xT$K6(G~z^c-6t&ht_%Wr*bF+& zRHqxuCh3*oE6y}UDGfzvPBiKaX-9&lOt~0orUDD2A8P=JpSqan8#ap1kfVy=YW-zI zC?GhEKskX!fCbbT9*!8J12qGDBHN;NE*17Bo63<zuOb0kV;M$uouxst8#|1tO|>Wo zvT-~llJu)%OjSR3&a}Qu2s7V#KlWrmgh6d#D<h|oTYmHeIVH&{E>0!2n+LaJJ=T3~ zvZPi*lTcWUIS1B4K)kX%b?~_JWev4WDC}y&Eo5}Dl^qr=A+X}yQ4TG@CV4l(VdK`9 z!lmS^16mk@JT3|yvNM&)fDLu;J0zR@uus)rTjH8Iv{D3%#C><NpHYT{RiNonz~$-{ zfD|KrgsD3x&syB{TLP$qHvy`Q(&yxaJ_wVY?QAVeLL;DF=O`A4Ckb~3Cb;f`>#VqF zr*Xm~F1ITVY6rzoSq(qLPvM#)l1E8SCpQ!yvEh!C)Vj(u;0(IXr3H2*=t~%lD2bDb zfDuVKpyIprg#x5|qW+mW;YyA#wX6-;GMVy@E499HiWMO#n}uzhnM{PNIL(bq>^cX1 zaA1QYM)-UZI;~SsUC!+oH{u1oP9VU*IKt4k-*J@=fERTGt#6jV#>5w(7%YMGlBI^? z2hXSW0bdc|mMB=2dqXl(KJJ?m$qdRCS*XwsG;FR+4I6|)apy5oc+vUlhsIZS6c@?5 z^sKhM9$b^h-4-n<7NJJVBl5|y&RRQo7$Ar>?#FZ5JK<y;Jzv=3G_@M=fpY%nXb&78 zUCL5n4f?hka!83DVAU0hN4SusPijK(Xr+9?ThGhf4+Be6IY5}l*fT&8MZF|&V4i@i z6M9BtWe^9B1WF1^1*Pl@3Mj;(u8i1bnKL;Wu)Sor$R%<hEck~JpB2B0R2OXAl3WSP zReWqPoZD-{*xR6_t6<_#FN19XK1}L7;w^BLgX?=qe(aO~bmCl(-}&M+Us2e&HqY12 zWCx2{f>`7W^EM<HoE2CYWINWCY$<XoA~08tevgPngO)h8xC$&`L%|`)I;9!O`R9Fd zXXDaY+rM~EGG!7L6M0HhNW{MG&`?W%6$?4h;8^U3bLm~p?26$)T5=6!TP2$ZVCi^! z+(G1OAg+G|HZwzazF5S!81dnNqj-MKRl&jK+CIz*EbG!|XR)govW{#~<qVvQwd}kk z*O8)dQ9aqY3l(VtK+?YIsWgr^Vw{k86n)PgjsR-~)D3v(Yd#2uuo+~@x=gIkFYF8z z*||*!7%n6u!_@)J);ULZ-buCVZ+qfo=RP&U>FKVx^FDH8sOExmCGmzrP0pLNF~}ik zU13rikOhUIFb4t3BZ<p92piZ&rB)xalZ;#ENk;>Z)Dk2Il!&Hwj^VNx*%{!8qO0P& zG(k#9P-hWI=PG^v9lj{BVq7Dzz5b_662Aj4z?U4bfxZ<a8q(o5&c=}~Om;$=35=uj z6v-3jwhcDKNems!iQSDZ>JehfH=PY{#MW{)SV`5W5t7CVfoDgZ3C@!Gf<7kO0_d5z z9Kl0O0VjJon+<m^Be=MllY3!s--}NpY(kL>7*wLNwX5vAH{M$>4i`I7)4{zL;FBb# zl-9T@P>}SV@2GRlI4TTV2tS@_k-qK77hzqOQFOjohmsZmCF~3?YQ<)vl9X$cNWE#e zY=K(A6nkigiwc}7kepyenWpd80FS23hiC-V62#qDXR>c7QJyQ&_f@FAXw+G9RKXGM z;*uKzV1SRXMeTwV&Net29$<?~1RF)zar0%g?N7P_X?0}r6lX&Bcq66=rLwK#6h`z( z->B@bV`#aax%R!Flrr<3zH2n~5HVZ|zD?RKX$h&ng2-3-`MRy_>rgvqL2>^dLZa() z482*&DdtpmV>h#Kcn#S=HFX*-;6G(u+^2~vQCCh&LSk@}5xG^qoe=P#a{wE(lFSkW zu@{LrO(Gv3Hw$Bq(?Ql*<J?R1D~Fc5#7H+tAXNnSd@~<rRdhZNY9A1VM3UsXL^#d& z8v0s?+Uc{z{esi~l4~dd@=>U+kK!T$a=<%u4mokjUKD7V>*O2X_rm^?wF5eUcIo=m zPG2@v**U_VG%U>JKfZI4fHesxAVOlM+VyG0DG@kqxGyf|MHzFYjolA>lf)P^cN&n+ z#1c3Gzk<cFO^R>U;@d-IcNr_CzvnDF>yx|PT6=Q%A`V649un=Mcpg>?T!&S=%+X2< zLz_&pXh@yQ4m*%;f_k;@YvV>_o9Yywf;uD?DEij4Y;?QsbHOMrXe@gOjX0oWcY%v5 z!2~F`>0Aw67hj-j%q`pF@&a&339w=W)xH`6F6yies7UFu5l`?a-#6JhZN!_9IH<my zjAVw^39wl8v9FXSXvbaE0FIT<Z1TMXTzyB8zb}R2;y@qm{@y{Otz_O2LCyWGr`bio z)aI7to2~G0_#v<Z2}TXJjJ}K>C|v9eE*VP32(Yk8^5Kkt^bj{C(<K-X1o#cMs<>Yh z-v+_SI#VXk4G$#HqWzG<93KpSA7Kgxk<t`LHcpq~S~>2L<4bD-;!X1H9vDPi=#A+C zChgl~`rCZK^GGY>62Hn-r(9fyvqZeem%cbd+f_ooy^7-kQs=aAd^d0`aM$2^lg2fo zq{tQnDA{>fz=GTZNns1<3W3VtpHS$F@a_7FK^y_{4*`Y=*!5-D;N5I>c6uicDoWgu zHeWj2$LWyZ)FL7?a$lX8eQ`<a!YV3~sjjwPftdmH??^-K3Pyk$0%&9%`R+!-E451= zDSRT!E*SO1Eq1*G2B&X8!AqjDm`eP<)}wW~5@Lqo9J$2O3C>cjoGgIn?n1o)d$*3$ zagj!`x*@*{o1R!ZX-Q<lg9H;wh`#BQYT)1-I|vT;*O~#nkgp226yGB4i$D!}V7{Sy zTdqs9<%T%OzMH7e$0tIbNxcUlqD+Yp4AwFLigiO@3I-yGQgq>T!e%Pow8|w1t*y_> zV#(JA0=sap5o&|WF|gArUt$G#L+~9S&H+mBhTJ)y#mFp9I1Y?mG8`Hv=*y&h2Z<pL z3$M2K!nx5Nj~pL`;yCykV>S~vu*F1r5XPINDz<dzC?!#iVza9_5u8fk&KD$MC)kVQ z4ou=FWYuCtu}YM)7AJ>wF84$KvPjtbl=ZdFyXL;Hz`fZ-Lx|S2&I)2WD0DlwZJ+3C z)lEup-Cte6y$&u4#SE3w!(Ju4P2vKHvD}7+OG32}X}P{z0&#^$UG=O<FwbQOc(g4S zVN>Se6eBS3#`ioD3L=gZ_#!YEpJReX&awb~u6wmv`|>tJDbaW5aw|N6WCRH@NHS(z z9^otP0R;gzd=0b<K=BbUh`B?7V?#XE*Fv_wS_E{kwh8T5aghMQ4@?E@Dat6R+9Q}q z#F<1or-TDo0-w5gi85-=Lg{PyNQtnmL;^4IW%MMssS*Eo93FW@F+;HFPC$V(-59wi zA(~s1YcL5+RvX^jgUJmG%&!krBLsc9L+F#6sTPkeesFxG7*6kjGveG%Kp~Ng>*To9 z(;AmtZcY&P6rpRjmlUzeH-k8Yz<;2@x8b`4J@>b<cD_jkh3$KcO4FwuIDSxE#7Qn& z0L{X_bJB6~b))_D<s^h*lr%0W1G;s+2q!VR3J8B6WnK9{*)S(ZoozyK33U?KqgcC* z|GNv(m#L8U#+~RC!m+RTJ<dkN+94ka?MJ3&@>LO}tPx#JgePGn;z>lZozvp@xyzu) zb#|$-@3is-=k|e!op$I?oDlBR)g1Z?>uh)%)!t${^i{J>FHEUX^d$@2z|uJ38IzBb z%zY*;*dur_wW)rp_^K(RGfo8~lOC`Rm4y=tcH;YUwZ7cBPLUx_IKC+*vV3vV-@F{S zLJ6Cbd_41?w$0a_5w^g2!8XAG;DR5*{(#&d6yz3?A<HF?6e$E>s98}%L7hIzCE9+a zevG|s00GGA#2#s!gW;=xd<&~@wBgLNH`v6a)$<XpYw}uh<MHl%)gwhaVC*Ey8cM|1 z#^g`VB<0@a>cKw`{(11vgMS|U^WdKc|NMXcXP5t8*>z{F-}Ic>^=r1TS+#NN*44|O zv0?M(t;=UOtzXT5I&S&dXRW<?`}VC{{DZaIx75qezG1^zr}sY`{xa<P%hUDdvwt+$ z-iy}1W6{jaABsLG`k3f%L|+hnL-YgDo{MK@4i+6PI$0D%t3?-!t`a>>v`MsG^wXkW z6unyXI??Zm-X;2g=%b=fiT+;nHPQD(OP0*c94I<Mbb{z~(HWu(M2{0)Bibl>w&=fz zUMza0=+{MW61`pYe$hunpAdac^kvb%h-UVfnb}WtnCLjssiGn}SM(UslSS)9TST{r zepYn5=vPI*C3>6a4$+51cZ)tP`l9Gtq94xvM_UgO9V1#PN^}45)=NcC5ItS=EYWjB zw~B5Py+-r~(OX6D5&eniF413$J}>$@?_9L!!HbqYYTLFow=7z;v$bs5vYAEu&MaCt zvuM9Xi@v|qo2S;QJ@x;K+<ZFC#csZe<`OqQw5R{eb~OKOPjeT|Q?>nz_H^?)ntQqV zN}7AS`KL7Zar1jL_jU7>y&2Wbr_tQs%~#Moz|9ZRJkZVW(p=`|Blc1AAUB^%^I$h$ zPV*sd{t3-P-27LXhq}3PUo{`<=Cw2rbMtnZ4|DU6X&&z8ztB9w%@zBpd8C`y&^*e` zm(e`h%@5FgxSQXhd5oJU@2}>uZa#(PteY>Td7PX7gXVHKzfJRaH%~f1%@f?bn&yda z-bV8zH}9l*vYX$cxx&p84^(rdn@^_s2seL;<|%HzpXRA<ev{@ZH&0lm=4oy|iRS5U z{vyrF&G*r)-TVg4;O6lMsTtjTBF*IHFVJk<{3Dv#&9BoeZZ1Dq&DPB)(CplN3C%Oy zyo2VMZvHdPv)nxHA!@F6^YJv#cJswF&vEk)X+F};uhD#zo3n?gd9IsR(LB%1pQm}g zoA0H0ftz2Yd7+!f9;)U=ZeB_AVmE(|<|S^vhvubjeud^`ZXWYcH6QKf6*M2?=Fif6 ztefwqdAXZkrujHGAAXpcSGf5&npe8{Gc>Pq^IbF_@8*|iKEchSAExFL-MpOUliYj} z%_qD0PMTM{`A;;T;^t9@t9gx^kEMC7o43+@s+;ei`7}4bNb@>3k32%nr@Q$WnrqyA zA<eaj{H1SK^Sz>vi~d=(-;r}-XV1&mK6Asm?TZ%wsCm#q2f525^hhPTOtew-v%@Y+ zMqPeikGw<lG0~SrdmlCEvd5^)$$Dg!=wi`2(XGQSOGjN^r$>HU^a0VQMc*HG*>lw8 zxTB@XMCXd0Dti9WgD!iGy8Nmhd7bDE(LJK?47=<->T=k_r87lEbfxIVhYz~!GwO1? z9(lFsZKA&reQDTb-%*#nkC6rytrVRvT6@f(%YLISx9X7>i{2o5pXhIgUG^V!`M-K( z>9I32v!XLaS06j*a=@s|4n6V$(Q8HT5dGD#%YmaV-_#@D6&*Y)E)ZQdJLs}()a6-v z<k_OzL~jy(XxQbT@hE!ayP}62H#2jZ=+Vawx*R+nMUOmNberf+q7MzbJY>}6%X;J+ zqWzYO*F+aAA9Oin)MdRMd8X*+M6Va!IqY)isLSW{$QML2$BWlQXB<E1^3YM2tM$lr zqFY3-7QKDg<*-qgkL!`Y7JWx_&<R?#69!!#HtO;eJ@RzX^F^-_y>r;*@KKjf>5<Qf zz9%~LMA?}q4!RsM>heTAa;@mOqF0IjVA$ozQJ25eBln2DDLUY!nVC~g8gw~o)a432 z@+8qV(aS_{8Fo2()a5Vq$lao^i1s>pX6D3`2VEXM>T-b|xlFWC^diyghFy*skD^EJ z7JXH;_llXBlU5A696RcAi5|IJ^i0vui{3cwGCS(>VLft}=u4udD`lsz9CSHu)a5)q za*1f2=%+=$G3>H@)aCtp<b$HmiGCnD@)3hB$B(+4p+_Dmx<>R|(SIFwIbqc0oqFUB z(LJJXi4Hzx(B;HYmqw4ADSD!4o9Gq8E+>t;yiJe1OLVvBYoh&69dtQ))TPoRS#*Wy z2GMQ9E-OY|eov45f#{>6e-iDrYS3lns7ufzt>`MzR?*9bT^=#&@>V_acF|p;FN^j$ zZP4YEQI}PEB#Is@dZy?XhFwk_b$OE>`F+txL|+i?ar&Uks!^BI^++RnoM^M?mxf(V z8+G|zJ@PiupNsxcw6q#@IepaSL_Knf=t9w2(XGQS)u_ww=#jUIJ}mmYXh}WjQjfYU z*CQ)L=ZUTpy<pfSjJo``9(jxC&qV(qS{w#l;@IrbBPWZ_6+KP#Q^PK4)a8wO<ab4X zD*8LoOdND+MqQ58BPWW^5nUsC-mps^8&`Vdb)q{&pA!A+uuB<rd1#uMIZBj8SBjpU z23^`wmsjeMUlF}s^fA#t54&`uE(bJvM0A?yQqiVn(B+I#mzU^~mx<mi`cu*8hh5Gb zby<>itVAb>9x1vm54xN+>hdBz@)FT+itZGBcGzY0sLK!a$dWQMbByQ=(bZ+p<?OKu zr$=5OdadZ4qE8IFoHOe3FM8w$qQhD#aM2a*pvxmiU2fDP&k?;s^j6VFhg}{u>hcvm z@=ekHoz9KuqHfUT+_4F#N1iRZP4p(wpAAi1dr*^C7FW?SmdDo?FtU;8bOq`blCHFX zkdR8qW?I4M*a{9rq=121WR+*aBZ~qFRfrfgi-ClsJ4Ba4QAB8fL>n|f1QL-z!&40K z@eC%x&jga}$8=_=|DCz_o^yWZ%<s&Zxo7U}s0ms$u<5!6QP;qY0`Cy$`cbZtMA3ki zOGL~^)>5!Qjz+*~t3{bbDQ~K^NcCcXBL%%L>(|rlpFONqV5<mn?uh$5u*uXzjhJ%t zqTe2PbLJ`<!Is3`Bk}ztU%}lHVp7naS>{i123f?^9{<?Jj260T_QgrA0<3I+o2u*+ zy0KZAoOm^YJ??F}nX>SENDvi}VCg^H04tA0z)0M!Z3$cjjH3)?W`Ragb;kMg6*#JD z_Wn<3>QbeVI8w&PScVh0N)lzVfwbywEeGR?K!L7K`T8G}o2VlMQ?9yPG{&Sf?d9SA z&+@{Tb;?^?Zj;m=B4k9HOGn%nfqAB$4!EmJeYE!Rqui}B5s|)E|3n=8peuKD79I|Y zNs}L20@Qfc9zhUjfU5+4O?6LnEn+DG^OtPei@VCD^&UM79-N#}1564ZyLj1T4hT>Z z8;H@@vTN`le0Q$AVCwnh+N8gw9gLNu$(~t9Hg}ZmKIu!plCrVuDthF)r1NWb=V_Cx zI{rs#*z)C-yUGMapTONi{jDes;VQvqy`1%+>%I`#(UN1P)&#D&T(Zol?EI(tZ)$H5 zHSTlp^2A+b8eMlw1Xshy7BPH+Em_XGkHx9qSDQsy2te|)XG8R#*|rkXwOHxRO-YZS zvYMnxs^p2S1q7>*2*Xe?DH^?YcAJA)X?i|GI0|u5ohiMNM&86^;`ucmE-+pD;FXQh zI<F~5rfZw6HpZ`+8yafb=mTSV-LM<e`|W4HTq1epc;(vHk%5cEhKn&R7soWI8NuhI z8GEz$<!>%OECOoukL4Bkh5urBTSA9xC;POuer4?9*|q}hPFI0`XQ>zCg*W~?sRIzY z8nT9p)r>bMXh#8oesoKZv_D{~i0S3%AP7vGPMi;2Ykp0(JZ&+0<&It&DT2n^Q{{8( zK~YHSf6NtO%fauKZw<W{M%yyx`rc%YO`CY|E)4K#cM)Rn_{73fBg*oj8#C;jxrFy< z;$gvCHGLvgi8ydV{9NRBV+gnd^{gbFj<=0Bj%mo&HTfKF^LMAsHD-UFF2lzdNAdr% zEYj0*5*R;%L={sU!=NH8mBS2U%%~jEvhU@R##oJh?kKN&l_S11o3tw|G_=6QwHBHt zZ?c0gkOuPJT|ne&Dqt_<+F-+^LLg0(uOqW-!qRpq2J?0xQSEMRNi&a;`+MAiXdpFG z{R5lvtUj$HZ`vpIQEy8-ZN~5R0NT_Yg|gBBQyDLKa|Utz(sjgdIr6g|75PiLN<>dC zM`5czlt_+ll*g~wM)5((PsN3AU(f)nk;9y9X*zzdA!_K^RQlxWsYfdE6l0Pg%j^>i z9;7Ot4b`t&2y-}F!yd~5^LZW^&&Qg!Tg8x_FEP9A(;OPgwT4Gex5K7NQ+cxF{@V*Y z{FBt$!!{nQK+tDE%tGVCe&`Q{{!a0mCdU)~&a<zY{wmwp{%rt9QK;A5hnmQMm{s4j zAvN-!IPU4Aaf+=vp*`22+RzNAg1m`$o6Lbc*ZmZ5o_xi{2e9IOfi5;A)s_>2w)1KZ zm*k-y6WZpxEAi|9LP>fP?d#zL+_5>FX(|#$@11iw<=`scp3PVr^s5?y?m#L51-z-p z>4o?<l@O|iRQ5cB>e%kq$dYN_VoklXy`*FnI>@FORQ7fiQBYhFg|b{bRWa&v;bI)i z8%JBiU^07spX}r?ZGGX~{F@)uVolNFm_hj0jpl6YosuszI10NaJlYDvX;~?0vJ{_K ztP;usl84hJv!$)EL71KF8mtWx=UZOxo!Sla&(UdO&21iMl3_CCzQx~&ovrdi$U<wW zzt))gS`eat!;KvHrds-{0gegf<YjqC1G+N%RHtYwCRm!+33CEU@x8tRtj*>`S;y*y zKn$por<hiOg6S$DV#eLYAEc1Z2GVq0)Onj<cMKnUl^JDzyUSAvQ#Jqn7X8@}%|T9< z;hn<IR6{;|#uq49h69+U0l3iQ;T*C!vhUo#v9_<AaPw{keZ6ymA)Lvt!v38GdH{7S zPm~R|ZWbK)&S$W$@Bs0-PAJz2q5EN!*7IZQPGyEj{%_Szw+?gihk6NuR#k~W$2*Rq zuQOOx)$VdW)<$!}E&j17Qwe>|^&F=3oRB~^M8P;-Ieao*I?ouX#M}uq*d0WkR}>i8 Hwr&3dW%1Wf literal 18164 zcmV)DK*7I3RzV<BZeeh9Xm4~Nb}|YA0Q??n;+su1c5U<yuqk6)jvtE%00000000B+ zoe8vOMRo4~-Ay+$4T8udT$-udrs15bI#uTY4az*I2q=o6*dw-Sy0K}r)fW{rs0oV0 z^BMD2^3<4U63sHtIYfD8Fq#+=qQRHM;U&=+r#L1WjW6%}edi+dIr_ity&-G8wP@T} zeebDLb*gsl;oEx`w=J4X_MdD&`UUU)>ZdOI@b_N!wI{r|`@kXkq5ix{boRC*F8<{| zUcCI!{r~b~&v^OUj$Y)SeqFS6@%9&fa=%}VM{jx0#^2a@{qm*$=}C)vx_Xx0JWKyR zOK(^_nSA^D6Mo^*H(d8OZ~f>8;uUYW=e>*l)3r-_`cu(fGnc*MAum6wdfs{e_VsHo z{)<bO`KOEb>S^sPJ$IJ=WR|`$OPb1L`CtCutGWxHy7Tdq+wZ(*^(*#X;-8*BOD~<J zuZf=4J>%p5{V)G@(TDF^61MJr^zSb6PtRF4nY`pzKmMj?eey%+ykc#4`v(tr+}|(q zPoFM2^zM`2{LQ;IJ@?t)ee2Fk|L&-lF7{8KJxgERF`2ya$QRyl*2$}n-+c3FcU<_f zvp&DbKfUhe$>bAvo^|=%_q=k~;tNi__>-4k`l?0#>0{qNnJk&??R8(YbaKez*GyJ! z-L!LN<;q<%b+u~Mels&Gw``tS`P@xAwx2Vzi@)<{<@!xGY}q#Z7yWhPmYZ+dy6!nM zD|l|js{4MiZPT;2ZrQeJ)tnu-ZQnWbBRj8Jb^kdoI>%GovUAgp(L8z04<`GALHkG7 z%;?$C%T6AB?@c?lY}?s?>krzy_c`I-K6~2Xyx9)x*J&P`w{M?uWBt14uDWlM{P^A} z%sz788>_(!FTL-DyS;#S&OGy$TXxOwy^CLc@Al93y7wi!cI}#7;9ItCJ!fXerki)( zw^8@**M?hm?AWwz=bA0sZn|aXnwz%o_+iiJ!`=ISETJE1xILWV%O)!~Y~QwVG{yVR z_THt~G2<n^_lW`X-H-cr-H+|YOxwTkevEnVBnP~-_|`p~+x%zrBVKdggm&YSQ&w)= zv|0UTd1KdLJ65jNiP$ylv}Ssz6=H=IKcegD_jYy9t?O=Fzj5984L_pud3)B`<L}W6 zkKFx*TW;PtQ_qB%ICyON{U6gt4OZ~x=WN@#Zr7R}w`|>X^UO-~<;v@4C1L;4(ZJ=0 zcj~)r*}Q6xUUJRgC2QB7eQ&>YGy2QS`q|!tg<81|20Tj(vhMy%xAJWLWc{j<_<Pjs z*RSbEV-Xl-`~ml$^8F{h`|FNgxw2p5{bq)Z`ySj&D(CvL+sWCowW-@ww{?}P)K+cD zUF_PbY3r_ZC52K#?%F0dbzN0Wth<=?cqvsbA?CVnQqwglbgAf<Iaj%EOVi|>Vv|zI zA(u9_p>9ghZ$nYfHl~oOP<6Hb9UHwM$6S@B%Q@GfYwAibi&bp8n3}59cvb46+M&|~ zN?R4psnt7D2r)%H-R9gjRSJ4ZYD%ti=rm~VO6;l}tI$?;rI$4NLWb8H^y*q)6=UIl zK_66Uj=9xutCFjxPWs@sYjf&ylS=9|VAM-AKaG^NNNt<+li0;p)2f<=X*QMS9CH_9 z&}%DwwEk#~v_M+m*y-<Grxoq=NE=e=v@oSg`j94jrdbQAg=oBv4If#T*p@EE(6Jt| zOS!Gvpm*z=OH8e1tVgpxT<_QB)%wg*Qrl^LVjZ-O{7PG*9V^<hP&9(ROG{K&+Py|g z(N%m$Q(8?pW-V%H>Z}FV+gh!K7(?9AX+E`<IW%GhEmIw|o=w&aviLv?)uvK)U9EZR z-)*X@R9BIe$l7o3g!W#GtSuEwsZnb(dY@Lgs)80o`!5#J!f7H}a*bF=Elt++#W;}< z*Zym9YVA-IC+1dzw{;e~bfHdBoyDYD+{SOp%uq`ho9NdiF>ELHE#l8ERN6H5whBQ! zCq}K>wi1(-T3aMe;Zrr)nw`zHUaVFVw6NMj@p@Ylv(U?vzPM)VHNQsRt7XtP7VSVQ z<_Y}aGm84B2=nP==`d+$+ZZED-)WDSwqC7Cv^pc|)9RS$NNG{@VzwMMi$TYRO%}7O zOJXs!$(o?pzi11!SdBiJjfi?fEz&~hLxWxy8|}Ep(#L9YjsDk&xwLXgOQyr0T3(ho ziJECk-%h{N52{-4OIib1MpG7Rb=oq?3oTuxy^BE$B5{zizCn9Z_z0blTH7fm);M~Q ziHVzXN)60hVlC#=P$d>^RTbgM5_D`dk6dcKwCIfKn>aFEr)_L<(2|IIG<orv9?^Dc z=c1Ywd<cUDZIgIVizP<ak!T{Dt@E6;Mml6&rA_bn-Yj0zxo@>s`l;S2PSnThOJarm z(RoN&pWArLqE=pv7GX)rHJy?Im%%xDqRm=M@w0Xz>9}ceYgkhJ(iZVm(43G%5<^9^ zt3#xvg|q|_+liz4?vlFNKQ=6Tog0q1UZFW_G4+uxGDKUX)1+S@G{n^bj*ytr3DLYH zoTAQOtsh9VR)}daO}2cJU<`HVHPNn0`e<v#v=a9^hGKxGWBJ9q62X;TuT9W5=<}n` zNYJs>wzrycD}h^TM4P0UW+XALXS7y&m)Nci60njaT0kwTc2c~ixflJeljLl~#GYc* z%e91U3pc8-L~rW@TS?rhug0@%>Nsr`r<jx0XwM`dSXUhk@rw=^Vx&}U$2YU$nFDKm zqPa=tHB2m^$6!HmhcuL=lvq&mE+EOf3=``ti-)z-S|3d*>L;CanmDjVR>cILN&KL( ztQ*BmnwmHjF3@f;KM4W7Q%X)8sKcU%D@|O3O8bbp3ra}ZF-fX)7CEhSTb4S|0jYwH zrWjpY)`){bl8DeRBV9FHt%$x<Bl4pP1)wLhg<H~^Y0jLbq~2N$&8gN`O84mtH3xkh zTQBY@oILG48bF*PjiJ@ctSjn^1?c<}v`G<XR0W|Td8^rq7XzmtA(0|4WEI$UF`m|` zpsUQx;*|n>Cj_f33LPH(K;MCe@d0ak`K~3cun?p}#9`ugaX6}&8P-TlMieJC%tWi) zgn&dv0P9grw1Ne-9q@`&p!PEcA9XEY;0#7atFRxW($IP+Ajx=10SQ_O8LdJ_|9T50 z7cdfZbo8)9g=ANuhxD#SWb)cjt%1Ho0zx`1qaUTL61qhTQ=~zHmR#>k2r@C7zD&nL z?@Z`y?U5u38Xl!rv4NVCcUd}IKTenxyilAg*3c$s!6g?ZgEfZ4o<2s0TRNq|l+se` zTvRpogkGo}l;rJv%+W;}nxj<AL{jNmIIWO`5<*i_vtj2tPKNYZjp!6xNDNh+8P+7B z#uG+EV9BvQYL1KqhB!}>8%-6FPMVN*Q~w~pIZfIdPJA}!q9es7I!}7NI89OzQ>Mm* zk$BNwwfc;x<EyO~14^!FS@kVJi!Ao2B(*icIyHz;F_(I>8Wx5vY}07*^@TdQ68cpu z6BhN<^qZ#b#JELjW0Td`5k;!Bg`*Kr2rO-8jai7UNm7f_yAi#`FJwP8@Ff}|V^WC^ z8+cg4O50c@M0E_X3Z(nRBYJnJkg<&>D3b%zO`5uf*J~C-UsKy|68lHwr`SwpBU_i~ z8sK6KTn-Df5-(~C3IaF9gkg>#7jFdCNY7(Ji5cKwY)Y&>ZLru|nqTTv0!&jDcNX|J zv#w|)aYM@y(_D1UWYyUhkTy(+Zhfb|4CN)(MZW1-NjL15gd&DHVILXcVg-Gz4qQNK za=;QZvo5S~2eb&BF6?%R1<7AYKk)!|zScl|3b$LF;A-%>usl4eX>09EFC=ABG#rS? zaVoe3nD}BR%zgM?RwUB67CY#tGGH(tgG~(yM;Wk^gxVBlt8db#$cVC<iI}=NTu6V( zg^V`D%0Nws>%`DD93*_zUmqepqAj+GrddlIsjVL&=sR^n;^$sdYk80slJHtP#EckN zhKdY8tqf8`+bOeN{8w1mgzcnhG<4SZK?}$3*X*X&NQ)4V>XOY`4jpPFTJI)QFs=B< z)`}L&%0gNt;*d0$cYH9Won&G}&%>R`B1D|mV2bK@k{-FTs>jR`|Fld8FQ&i?nm+~t zIz_*fRjUt;jaO3JuEo{2%bqF7L95w})WJW&@M;lRux7+Ykuh5J{t-JF`A0fL2D&W6 z2GdK7?qh+iud@mlTdP}4*Zdk=QpP1Zrp0hCuudzXQ{a3Zca4Ch>q9EzRE(>m(_uw) z7!L(0E1_89M@E=Banz-&CER4A=)7QB=(o5`9g<c?b&Hn~Ffy^<#J^I<wqTI&{?Ni< z)BfokCcIgAL~5e8>r-Je>(?^<@UOLHQb;(?8N)wfOX;{&2v2oDVIYyUhceQoT=ZHj zLa`oRYsV9^KoLKcos)oVB>$uGVoIoT+_73XouTfH1S#Nz-j-bAjb=CPwC1F*)#A$( z)NvK>NQ`APrc{0_cQ7DLv3|s}Vv`zejeE<%(s7l2B|Ajw7<Wqik~yi34`_ut!T|su zXtcmcw1E9$HmErx8ejY=5iK^<TIdj?f&mvg{6wh=86fP9wnfY&=FsYCZ8U;W46TD+ zs9mY>NVV*}oP;UFAP6Yj6~sV=gC%a1Hm&d!^#npDV1em$R45EAS-nBF4%RP@Qipr4 zQxG!eUrJXNZ;N=<L4}c98w*-7Is2MgD*dsPc-5iBOh7v#^BbF<5fu|H60u?<NI*mw zw|H-|;4wh4lCxF6hUXOxhgTkr%uKvOOQ?dOs*%7U@Senh73MdVsDu-%g?5!zS2N?i zC)9Bb!`9#h5fDNW0iR5>;`bQens^O{pe1W@BsiGHg#v;^I<`XRU@S@Ea_$5ATZ@Vl z1UKMhNCRt8lBI}xfD~lZzT}5E1V#@WE##n9Ko15Kh7Dby9W8Kyi8-L0Eb(e$ucDo3 zeFv_p&%C}>$F}gz8YH8}bqLt`&gUlKx`PP82mSNf$$$}*F&HvOAfR`Q7fH=%VI_ZX zCyE_RO&rfcMxrEii^2ve%K%pmpizS~0GQH>VfyGeh`})fC9^HlP}JC^7OWj!o{ofs z2v(nwl9q4LQNdRc_t<OJXEt~{(cUyRq2>-K6R_sQ@e$$NA=_|*&>InbkL5026Whu# zYHZ+Ru}SmN9WzGL(>paWokE=*@rxK9D^Uw=%m%m(3k3I6Ql5Rs2Pk?sDgt{#j4Dav zb1KD&ZOB2={Iy^W2#NMlpQTfuSb42^0s<*WQA}8j%nE@b?vq(0i7ykVLP?`&tTxfF zJjKTvg3|u$SfN10z%nH&u&si3tF6O6Eci=EUX0m{C#zMLrKm~c8)M;Acxo^YD2tqh z4wcc^gbn6U$+3hlm;eNVbU-dx=zym>py(4=8DkcZs0BTdpvC2p?!%lB=jwxNHc;ml z7g>AGjP)MLw%Rs*G?>Qusrif=UeGSH3z*1~liK498YT-ylMfim()%1*6l4bblmrAs z;P|6u!I9A2`U;(8j6Doa$rhvr?*^4)$213otX@)TLq^C_n>-EX06+-F5--=0Kz+y> zkxeegQD@#zCx^bqsFfJE$))*J-Ue3HAcDjww!Bs|;x%amJ;w%QgT>51M-;^YcQlB; z$li)Kwe*Qa1<FAoOPser5|VV_v%Pi&Rx!I2qhgYOIAbhez!c1EtOS6J0BwH&Hk2*_ zzrbKJ{;996kUm;9D?AAe4xAWLGnG+{hoO$zHjXc-p#JD59iF~)sMZ)Kr@}M9M%J4o z$N>x_@Cr~zZI%V3(*kjXKmsG0uEs9WdDRBsp<wTHaH-Tz@@Lk77A<y-ILSRQX{CrW zRv=KhmVXwj&|#9!(hsnlO7A~l4YAz~j{!7j#2Q%yE9+lkFfA+Ef$!8tC0s@{O%1#h z15=bgt4V-PS9m*^EyWwDkqn5SC!+md;BWq6C&VYM?J%B`lZ%~;)dDzgTUW1YahVXW zXhuYx7=Ry(18O91pd;s;?SX5x#~B`x=x9NjWNrcI6!=*@rdNvrESzyoKpZ60F<kYp z0Dg?^f(O?a>#YntVDji7Nbvx0;oEET#D6UUM(0m`v0N}{K^YJp5|~<2f*P2r#s_!~ z)SyCcV-?k?FdP8`m7r%>Lm>Hj4M35YRkPM_5tcxR_Q%D$KtL>8B0MA6h2^W`h|P&& z)5liCImGwc86p?5bx|`N+6A+r12RI5+jYbqW})D3kSF^aI1s>2a)LNi`T_$33F8K^ zJGVAe#cr5BI)(UST7%l&Bi2)5XF3eY-qV)NAh98%9+{Ql9n6Oo+&OVt^-V1%8YYY_ zV)z_frY7i61G9pA2dwjq(O6?8Nz-VF8{`N$bOXSg2+?Sw;sM~jGOG~LKIj-cQOxmz zbj1qsTA<Vu?p6dF377>fo>kX+6*<mCjw;w&GnHh*D9k9H1_=~!oh7btx*Tr6A+RNv zIRHAz3CIAL1?UWy-593UU0hh<GvRC!1HyL3t5zpt6&3L#qz!PM_y>2y#xw#}3RYHw zMy@f_#eEu8K4xQZoSle{Ycv`iOHiT=SB2OLalH-=Y(x+Bq%FpgH&z>r({qj^njD7_ z7^Oo6N4#@D3C#$&4qP9UC4nvKToe$89@<COC5}}>lp#}#6$Q>qFq>OP>TuWCo7j7D z8d?~L@QO@3th`3sm9fz!VKIUU?qG~c-bo+?a3Bek+NWEpTHGrO7;Rb6QR|xs1Hu;o z4~QiqP6Voqx-(1I8f^$N)e&;z5E6btSaP`G)8NoSu^|G^QDgRHKwfhq`+$Gl7>BfJ zEN*Xr|4=V2`mV+&(%$0AF%W(+=McNK0eTB~ZJ_!cUQocQuMGy`=T^9FsJ#Y(l6wcZ zGK}Iw0BnOGiNs<0S0y4GfN+k1M0P?xh%FY}Rzr6M863el^;G~bc*y|IXnIY*Z5={n zUn`*egmsMvhf$`pl&qCgZ45jjhy!L2uy<!y9vDlL4u%uNDZrE!)2xihJAk8=>#$E? zoX%EbMPLLj0VI+~g*!&bmrzAQB#Z4j9EC!VlX0-?F}8@DiCr{k29qv$t@u<hJpmaV z_y!*h7=Z9AMh=mJ!YYXsGlp6Kw+G75!4_-R4yYlDv~Hlp1z6FbZADP0!FR#vudUZo z53NfU6E1{T0LH}p;LaS<3Wt?wZ&fT5z#b$pIbom!9T0=u#>x|cBMcf;nCe=!nlM7d zfsy1Zh($1Y;D;Jr0Y*TysKT-g_yMSEf*Rs)L{bAPf&NN($2l5Ihz=rv5AsIIYVct# zFQ!evGpYc<;FsdRVA$%@uy6EX8p{zeoV5-&77-kXIv}I<ttr|T1ero613u}!i3O@{ zD6~Cv*I9N0=}0K*=MhV(w*QLZCVfIUKF>lp#4u`jA`u)Gd!f1Eg${gOb~Nravk3<3 zBmg4jB%mvZKxgQNFk`^#Wr4)%1|ES`s><L9&TH|DQBy>ma9CpR3lVhCIwWjX!vcB> z%BizgL`XRk&mx2_F2e{Yq)TMO%ix&W>&{?|7TU3tnxJ@x*9}n3X+Q~al2KHckEM@M z8{kfae;jPYf@p9H?Q;c!=fr&p3gNIv0LTU`+gb-W5F4>WVs*h#JJv{T<gFnx46<I( ztAqiV0Md`(QPUU;3C?!F!z6&Ig~I0Le*uG`gTE^54DAiBO(C*~S%$VDp`yX8#X~}9 zkwKsXpx0<2oa{j;T>QuR!c!y^UmRz^Kdyn6@pAQULX<=W5}|{d-RSr-@u=iM;ls#V z$p8(A>`eSqXR0B@s)^Q}LD$~k!WygDSPpb#%Q|Cf2}ew0YHh*YlYu@01udRrKOO=j z5ryDUy`v+#uSw#dqd_DIvG*keYF5|)Bq9e?8!nX)*C{tVOB7QM9^WGF1WM+4?Qt+B z(-7j27C~91%E7gS<xM0%^!kq|3gBqON|nsR>hD1OG0RaDjbRduXtole=Qshu3L@Sh zD46}k_c0`}rSUZ4?Eml%oZo@iajF5*2`~ury*7vk)<hDJjs)RLOpS`HjLw`b@c~8! zL$%gESf@nK@SIRBq!1JkD1ZnpHR(eM$Sblgpq&JK5?q=a2P~1!8SP@=7eC+dA2H-; z#|CQ%OetaR(Kq&HF=%?S8r0e$6{V<%R+A7xTmsCG&n(Wc!CEJf43tP%!a+z$C_?f; z3p&SS+z{SrKr>{{M*CaDMcFk>ybj&Nx^zf{NL~?Paho$4?VQ;l$+pJM8R0F&wsr?m z3%g_O2NFaAi-z@t^$z3UmEfiK(NTN98Jii5NLC*Qmn0v=TZbIO*dk^_W=2M#;@cy= z8e9?`JN>_dBQi(>76;)9P>YPITX#-1XnSi55Q)Sng7qX6VHg5MhT6~!$g5>C2`X4@ zL=+Hjg$NQ*Clg5yb40QX*b;qVW8ew9Mbpg260_qvjITj}&R}fxJV-A<bB+6msYS#N zYmOurj7@AH0+H|twu{&)z|Mgr6C6Svg@*7c1{^*c0aelp?5#RVf!j_t8c1q}E3pj$ ztfYdqLnw<5i-Y4AE9+Byn9ySecH*7P)#B<!4iZtqj)*xX6*iGRT};EN1Ybk`Ym@Oa z2+dd~cQ%@u)~J|M@PPSqwzubm1aUexcH#s_Lt98xyP=vq!M(~j6+4N`P_R7EuN?^- z9eFHx1Yr0rx;p}C*8qZnu(PZ|835o8&NKtFG2{sXr0tDpJI6uAM;$H&E-~wgD6DW} zw0DT_>})zl$NxtEVfxzs1SEGzD59T;*pUJgIMp0Vq!1o@Lh*DUg2|3<#Nsh@jyXi^ z4%-=F;^=Y10Td@{pD|d-&>~KkIDcXsAT6xyNctic61i5^RnE7w-U6p)?*M6ub0M37 z0M!@W>6{``xX^VZCjl~nN+z&|24gViK0wu4vNfbncBt$C!*uwOfx|;CVI)2%BPSDC zCQ}F-kJKNW2uF$m(|}pQ83<=1tShG^B1wo*gE#>u5~D~+7c3jB%Ix$!ZFaWfW{e*5 zBP0Dunj#ql*apkacsr_rT!+Rf4@9UOkmo=VAgLX2Ar29+(~wRT5t`l+(-BX|bn<|} zcQNl|^EZyXF>z9`NG8nK@Rm2&iaNF=)&Wi+^g+^);$+c~=z|qS(j~44I1Oe#xo9}& zq%34-Sr7$iyy#%s*igCGEg&0#Oe@gs8r6aCMs$_T4m|{>-J%WQDcs3kP;>UsX%W69 z>w~ieI1MC_NOS<02lH&eZ}DZNlUpJW+HSjSM32#0PDOGG5=ny@ZzqZUt(cwphEXe( zLDC<oG_qt6pLziMU1!1!2gH?-r8PN{K(?5W;G}@I#70|w#&INmj6dC?r(4n=Dtql9 z<+ZV>NEQPAC59x(E+NhAd=au3a8n4HX(An}lzgQsI5!f%kB}|cZ3JADsHjLPk(j{u z(Zl+gGjoX!VCf;rT1RsA2RBQqwZa=9gOE_ZbRJj?$#aG}b>fR*XJj`RHF=Vx71(^A z^*l%aHm1NtL68T<HI-PsK6@EC*BE*Ku$g3L$h6qJM09cm&@tc3#=KyX-kq#$)z zJUV)rW2T1K0C%<~5sb5_Rj*J>WL`<)Bz#(wJz_$N0x3lTOhfulaF{<-PK2_d?(7FL zPj&8yY2vd)*wavxp@QJ7iHQ6q<ck|j?ABJ8l}~?Y@!|+Sbq0|OKSI81R;2RUE(O*k zx<YDX<FFHE4OmA6&p=s;g)q&?3zj>AL!|l1M(ctBYAi)uK=y*1DeNm`9O-5)flsmy zSQvc|T!d$zJHu%eu6A~mi6}K<PST1f9MS`Hvvu~U(RGP(&4#dV0q7tNEEqk@ji-zC z-a6v$)IXBR8}ctP9LOuRPu#(>9U%+yl{=?}V;KU+7QzaMK)_8bCjeMn7cwR?#u7>H z;v4<bVJU-~Sa`$JXhBTw3h#sTGI6^FT??FQWRBDZ2ayfk6p%SET(B}Rb8XmF%<a?f zq&?jH%Bi$u*2U5z-!chtX!$y=2J2=WFGgWk@vIzo2W#`k1)w5*2|zp{$A(;JCW5bw z5km&HW0TmkAdVz^fz5%TV{qDE#L~l3BFbh*g*>yyX_thbOXGwA=h+4f2uz6z<Q7E% zU<)irUYDe5ao&s_V)~NR(V~J#Ceh1VCn}NhC)Ln6MN%UXM{2Q0fisMkH#UEAb|PIN z)X!P;5sFS|!}=lm!zZ-Ppd-)EU}=~89RlV9c_6L2!@VZ1hHwO_=+g<wkR~�|9IC z2eHNjwvZOtM}Z&};cPOz8Zz=42j=w#XCty~Sfygx2%6w{V=>^S36W>nI6{Q1(+o)K z4c^a!+$*(%5sq?XgKyx-#Q-B1W<wDKI-7GPSw%_*AUa9+MDSdC0lT7(nrIFO^(1+m z1Pc;Gn&<?43oQy3fYAF?0|F6Em`wx*Cd!tNEg_AHT_Ix&`5}hY=NQ5yCV+3-vbVCv z8mF=%v>K~yjOYTqPB{c;2}}u>pmHUNgJ}tuu(LT!ML`1?6o77kXh9Z95lhZXB&)JU z5Ol`a@l1^Qf!Bjbk<~`shTcjDhC_;KqS&JtPvO90hhmi`j17{=t6ri<yl7eIoCnl+ zQybEV!I22iSm!1r{{}%q<^ZTOrataEDg(Wk4eQsaW*`(<gxaWNr<fFmOxBpTS5lYb zBMuX1SSI1ARNfmf0g|_i#WjgE9o(Mq3o!bLTJlY#m67k}K$#Yx3f9XV-%5;?6*7X8 z(7QN1q^%LG(T~ZY;Ty;f?f61)R@=citDrKuae_8WgNcwaY+L6Wk|RyDz}AzCWmx5m zX`p=xB!~ljknV=VQV0hXQY&hQ;<3=2Tn3!f5&grYa83i?QkY2XG@a~ZG1vz*%^T^U zMTf1|l30X#2~_tqo_GM$wZ-lti%hJEI3MQ#$j@;uvfC19DD@q{=Ge`|b*1T|>u)%- z(Rm4+8w&;Uhe%0FmGi#{$&g!>iSv<w;dG4Iloi5+d>v*%WA6yYXPps>h+4doh-XF~ z9PVe=$Lw1wd<cJ#dJCq@TY#{lohVs5wcS3arg{s3P0`X?ZH)gG=@xq<1DvdNh!lId zBjOOexQLSM&`gK*!{<{A69I1<BMGT?K*Va4Yz(TR&;_mkZig9_sPjuC2@hL5Y;dzO zvdDoh7{Rz#NJiW!AW9Oj@GUv>&ay*=f#uZHpCzk1=_aa3Y-BW8VIX*9I|1&YAc_&R zLLirdCl(EVn&bqcyQozTD^3`pOZ1S~fV3?trwFlEus-mg;{YUUTOdVz*<uBP>8c}5 zzEeVPv5TM-=)D&EU*7_jmORbkj|5gB*%a8zKECk;*H~msBRs8WB$cEE(#VP76Roa! zohx$0K8}=YRFD9GA(E>syMobl!m?m4Br}rXlnpb0!QdB@qe{*aX*-5aqjNM3?}GoJ z%BfN!CAEhnseS-5B2?z{1p-8P-tkq53p_Gv;aX>XBv-UqJKL?QF#ZVjl3ic>?d%b% z3L7e0=YZOfqk<bw0vT06WK9%rM2m{A$yqBpb;!70L*a)M*E67pN#jfC$c&lIT4F!q z&Vq{*M6zu~_>V)`kh4bqXR%obyk|7X@f6H36apbDTtyB-LohNR!HLE=Gmv;2krM=t zV-C^zb@*YGX9B!QT)B_dls-Iy2aO*};wB-`3_R~7o4Pel0}HYiL_55n!6qpWW204A zxd0^vjUNGMsiWx=!;?=8rVYW7#wm-S7%plAQDQu@`luyr9J52`+Wa$A;KYZ5S(~U; zK)QglNvAqzmSh}%3>dX@OaVhs{}uKYEG@1g#@P~vtSH$cfgFg4j6CAVc40_w#OuTr zkc1+1ulX=jQW;4IW5>vmCMy7Q7(Ge?Bfc{ZI2aQ4Ym19ilQcxF1JMpLi^=Xn!;l2z z0uz=7dxX?+l$m2xol~2LUv)@arV8ZeG#riT3Wbi!y&6BG1O3G&M`SyI0DeOJmh_=O z@d5xSI$QjPivg-iR0vQ@wh@Sg!=>OLr21!Ya4^~A<O8DH9S(%ppJYWBY$gLUB*`QH z#0}uFa4rdf3<ALH+`GOU(!tFTT~tV&O^EkqGg0zKjDuoLQc>9^q&mfKxJw)s2cJnp z29<~;R^w4SP|=z*z}}=qFh2<;v@W;7^Q}Uk&_Jj)@&fXDLU8$?;YxCSkmDqp6noXl zkw#)@wZlbt6`ixKGIkb{7X_XDJD_MMVKmVO65v%!k`d+xg{=XA93u^=6S%zCbVoKh zhDeN}rqBpMUb(0lHv(qs@X9Jmlp2>SVTBSdATJMvjA7K;mBpe)umehvafNYZza6J6 zx-_vyu}DwiqB(7Xm^AS;SDF!i7h{r>S=ZjHXjBb=1%@C;!X>Z7ya=}xq=SD*b^ysK z&Kf2^8(^rlNCqczo*40B`snm#>L%>X!CM46KuTTIp|54oK-wfJN0@Sv(z2Gq3bHvV zfD%towLt+Sc&)V#ynvb1xd@0wgE5WM1Amd{kGPK6rLIovgdHialG)T}){wP9(p0uz zB0Jfr3nhf1&(uY><Y3KB{hB-qxXwz606}F{ZLp^9W9o$b(8dj%od`fuT12Lf>mXPa zoKr%A;9iM&<Eu5!NWxfgGFaz)Bj7y@0}|{TCJ8@EA&_&L`;e2-4hkeIr(hGrz;+>X zGSqzuN$4}bV_)1B$w^>0DR=Fh*a=QfCADEu>VhbsAjOf~T9V|!W)epm#gD(;1V{U{ z`2-z2G7z~BcwhEI#!~`@z<eMkOf@mG1=Ob^{}d=al1oeOWNYtJO)&svoy1!E<UXxS zZ~`ZVYI<?yVp)B#OW!G1Dx~S4q5w91G)P=8WP1?%qRyzck4y@t^Wec2DJe-V!ODCi zVY7;)g3`w_I%jVH786|uyeFn@TO;5s0Xa8R@`KoQ#-YhRc2aR7y@rUUZ5>QJ`~ec( zY8T}>fz#k9^&K@R9NAegJ*6-W$Q)T4Qo_#V0J8x{!M~(31{|x81W5XE(7Hao3I*M{ zgbkPmXT1)6Juf=5A`F4~*V&C`HHi5%4zWjU8wbaT^RXl3z~LAG>7i(|S*Uf$*~SV> z(31XJoWRT>;cSCn$@Xw*DX|n58^|&O^dy%C%VKur5>fWxogoFOLZwTqkjzg|0%MZ< z1jt=NcOhEYS*!>GXP{NZby=(%`4<(i90gGrO{I1^eGQCEd25Sa&fZs-Bo>N08(U;G zu$>balVdZ^Br?7XTYyw@nSm3>qQOk0C0Wa@Yd|oDoTTo$7N_t7@Hjk8;v~T?pYlHP z-1z%JAxW+Ws0}?{?;><kVL+Ryk#M3jVN=2m{Dj~YqSc5^B)zLp%?sQCblL(7ljaGu z+Hj8m@3Cj;>~E5s0dL4lA)f{34_}phNKkER^YAu^HyEnGZgG}@Y)rCbTs}#eI4N!b zXB5KN?gV|pKtSq}e?rg#zQ9C@zP|zQ19;NbqaBlms@}>4loV1l@D9Q04q@vwxrCcu zW>G`}Lr&#q05gZv?@<G!l!!fRY)GmH9AG8vQM<4SzT|Ka*iA%<NR7c=qw1rNr?Aeg zAqFiM<*1b1;Q|!AE|<pwhUnND$*P^2TN4l?FFF&zriKMutS_U$w|DK6O$`!LSZK!+ zh)0lchNG^XA{~>{nX*3?y-Z{ew-(cv6N@VC>sPab-h?7rI1#5RI{;ESK_$B;AsR;M z$YIC*aLPkzXG4FKu2~oO9+bctqdpWPh^!15+$16qvF$iD)He~t0`c)l;(#K>$?+y5 zj`Ce}0Cp!JL*u&vDyQH(nVgJ)*03s~zqaM*TP>UhO$Y`_2VbGM$=fa%iBuwhu5mvH z6&)x`Y<`q9pHA9yw3S7nIvF`tAF$?P6`N43mM`3(B(zU0#;s;cNiHyqPTG$|Uu!%X z@zxbXc=)^=Y^orgA4ds$T}Tu0Z7!gq)FA@u)y`~pi6PpQ+6+!V$F{P|LgfSTQtBcs zd`LkA8Y2Ellm=l(q#85~Gu$_4pnB~ZWMnpak<14RIzSv3AY@Q4Qt~)_<U6|7mw<{v zZd^0sdbqNrZ~-qeFQ?sPU&!Ee3Y=Un95L&5m5c6()f4N(J2iV#y{o?xVM_MsDsIX^ z&u4s+*7!v+U=5gJGX_Q8_Vt^%3ljQ7i_ofuM!DR9%5;}iqqoS2#;Zd9R?aQ(Ei~M% z5M2z95kOV}DH#M%04m5YPQc#eb0p_#%h@2dSfkpg3XlfouAkbDRPownHnVbiH5q|; zRUsM3L;<G$GLy<Zi$kXNY76*_(GqfIKnU;**a480s`y3}va*v4O}HzD@)gXuSUca^ z>F2oLXn+1zvCm+7IMn!Tc*NvibhvrI>bwvHnp{099;0*GQM%|-Ot=KhOExH_$y^Bm z1Z%*Qb4I0DvaiW*keSrM%nfl_>IZO@Yb#U?Deg63$sE<8mb1baV3Jhea0a{L+mUL6 zB{(VYfqDiK@UcGoIzL=V=dcwQ$2xVBU>S+)9ZHGp31Sw(`P1kQj8WGX;H6=9k^9T} zaV{U}%s2&PB#~z21Q+reN$jHp3CFK82E*Aj22NJ1ljq0`=z8Roa%H~4_AhgCMxbjM zs@NB}HGRDmsZ<r1ITjeVwz!lB>xVy7^-z#VjsaO5nX*Zo?qtE<*I~3=)k3`<IF=D% zs+FBdjXB}61so|rPkSol38H5TK{YCb0lf&XM8gswDqQ!3V&`T6oEh*zVvpp<Q5cmC z1rv|P2X3tKnE^Sr<TevTaGDF}9QZpJE+*oNElAMK4vH_?Aa@F*8W=zuphI0ae*j9< zd?)KDU!PJOB*!@;3){t_6piFQ36-FOD*&=LovI8H3XlNN^<CsIfG`^CC*o=oF}c_Y zKFCBG$fv<EBe*MZ;c^G=vO(2hI``gnU@o?2bh>;ihp+J=MnZvIb`lR3dF6sIa+En> zB$I(uHqJaCuqGvslkZq0RsTRX%pM^FjEJ;08cfj@fESS+<R_J^uyOW14HTlcE>lG7 z)qQ;~@k!Q+sq<KgE++$UL&%UVOawZyo}}YYGDhtYDS*^fp{?*&v^^w3v&s$^rM>`- zI8j~q2}`~!g8&{jgHAKm>Bh22dS&>EGfh!SLlK%2jXFcxk)SD4E=HQEz{2Rq8UW&_ zE++bhjp8%ps3N#pe;E-92u>qVPT&w=0X2q)BgW`J%>bXswy2#;g}uq9a%9n~NWj)u zhEZK-X^`y34r6LlEy{sx91n>k{puJ~)z6(Xt?v@T%y-_8JsA*TP+Qo_$Z6!3A3Z@% zNpgydQ%UXS!R=U&bzhq-sg=+q6c%I7fwd42uPjd;Jnnp1Lv0fZyP9wd8C`5;hXqRr ztT=a+LkqA;-c4}Wxb>xQDf#Mv7KR{?i$aI&OeHd4L*4rh$tFMSQ}x%DxMmKm6u}~K z-<|Adlp$diXnGWIxq1a4#Yi7v>dwit7B~Ht0P5gPfGVT(IXR&Z!enPVTg#Hr2&mUN ziUs0H!kvK$uDjqmD=yk;obZUt?TUliK`~TT!w>OOxaNrDQIgZi4aG-nxFaRCuJQ~x zgRXOFfgK6@5=J9R;-n&AL{bi@_-=in0O_8nf2K~jlH*G)YXi1Sro7`yt#6!SMM%nK zVH;;A6Co>3bK?@b&Osj>*x-l}KA(h6>l9R%b34Y3ctNid2rw{?F!b$rT%`lxMcqK_ zn<cO@@dYRbOCY^usiFA6^QnEnR|L2v3RdObkc^a%`=&%PgR(^yDzpO)n=Mnr2BA>g zd5jcZbiVqb@s%CLMY1kEt8K3b*W_`xMGJ~WsL}F>d~&R_)(##92x5)<@tpQfI2lLJ z7q&P}tp<FcoIg6+1II^~vQ$`uzO9BFQlbY~b%o*)E@bJGnovAiDPQo`^D_6tz|vF> z5au!V3{XT-F9{r&Cm`#Dp3ztt#DOD$lEP9!Df@x~3UR0_Beq#)O^ya^FWD_}i5v(E z{$a#t#qT231sk^{SHf}?9~%tk_L?yEHYn*Tm^jqSU|WC>lRA%h3moO(`d*SB`{X~J zIM?HMzBtWS6gIBS^R+YC!J?KR7Wu-w4G9Kk1r`R`j&&tlikylF%vGb`BVy5@B~C4_ z0!!FXa0s$aX-0DXd7s?bxOCR`FW!?(nS{keo)Q%jv9CKc)Y4zYLQXU|7W?5`dRH^M zVmOeNTm#uw$>srAI^G_45V;zN>mPy5%+Q@L7V#}cd^q4Jo}Y77aB#V{53>Txy7bvu z>?($=BU@BC1LtBbJ1@y~q$pfePj>D?McM$6w6A(9jpL0NCnO$4-?N7!z*+%y10MRC z4}u|V23fK$6YKK}J3~cwZW98A3(3fEbwIOq&XJvWQtkTNo;caLPmOSTx-0IykK7ol zx!_z$yrEE&^CoQ!atK;inA8SjL18G&L4fi|;_?o{2DVYD)yM24<JNi7(ZD0M1jzv< zqN$x@xGY9?26&?As`xHVkWv!VSwzygN}qp+FG{Q!*9dH{|0$Ei@4yT2B?oMvZv}~l zbhwSPabydVoseb%<LEp^@`Sl<gAH*KL&tJrccY7XgqZS8XTuw@wVVxBQZ;IXq_INa z*->YLv!uSDkIA+GdL}MM@DNkL$zIN8!=1|rF0SU}UKrf>;?oG5P~-vzm8fj(D*Nt@ z_tuNU#ZJ_8aPI~9B#9}dHEs$NB)#W5>RdC93d0t{k7rt>Z#(iuSl49~oiEm*qy<0; zJA;c_v6-kO<=P}tZyGLJpjI%&9@^oe0;dWjCs<LY>H9Unqbc(t8bP%LaW~eP>>Emy zXG`>b6{;^9b(S1eaD=<K<c0tk;3I5NyC8+L4UUEf*rF1_MiF-0d>L)~ldeEo9a%iZ znb1Anh$%v;Z0k6M5q;7(D*NjgTCQiVeJ?1b%zUTs8cjV!43~m$lXgp5Lh7#|@>PDm zZY%pb)XrH@-2aD===vN(Z&q@OIhEbm%`6;VLpD%Nokk1zPgxiDY2r%MmD7@t7~Et; zZk2B*1U%>*zy_@(vjjoxMIug<$j8Uc!kFW9kagBL_Y(ceq2(?y(hU+w6~R5<%!gSO zozH{X2Sg!}B)KjTPV>EnzSg03`Ydt3;Pk)b8cKkC6sqf^xJZB;@D80rPF%7V1zP4h z`NsFXu)k#OfDWKtx<0kjmrYf6j<6>U3v>C8@0=uHO~MI?keI1<eOhr!1P&YSi;H<t z#$0J*_ru;KF~-cD2Bb5w1Wv%OU~z1d;+wVj_E6bf#!Bh$Im^!a<Zidto*cf2L(#a0 zM7t=Shm``?Vbv~kw9>-RCX*~0Qs=V64y2o)UhVtZxDnZ=I>o1;4v7VdzBMfy-LCsw zFiHy=%N{}_4k+1O;NnU!0m^MUS3}pu7w8&u%l5du031>RtQbMHuZDn&I%@+eQo3x! z6FkcIO}0)O@g^h=sxK!anW1$8ELMH&E2RnAaaT2fW92iOd@li4-%;f6OQE<p&_}z! zchG1nnRi4`bARh;b`dbOxh45#D?A*22<$+DQG+d`FQW$v7dwMXhLSM?ENqf|I3plE z#7)U`2?hiKeuJ$l?$^Y(L2$Cpl*x0$0|~TfKcq0n2gBb-n1Vs1G{upP)1|mpj=SXe z(wcyHlYF}e1`!u}V|su|`!<>WHXraj(#p8RuX5EX7nk8I5ijzkFV4_*m5^_*;<$j+ zIV~LD4IB&HHMriSag8V`vc&*Ob{-b6AooC0*aEsjpfdO;6#623yS`!&M}Yi8fMEi5 zeHk`*H(Q;Z-id>X5_hD{mk#%FIwUx?h{%lGS0`p)T++I*ii%{atL;}{W&r&=(onmC z5uk<u8d*oayOHop?UF|dpUAQcMm=$hT`z&b=^Ie+lBg`E62GtYXkD&^m|-|aF0pii zvs5c53*foCP%psVt>biDq*1JH$nV0YC)Q3{5}EKI!Gsc`Z~CMfIQYg6f`k3FW<W3G ztHLeCw@CXUP=g+rZ|L5Z>(XqwAr7+dChGI?iI8Vf??H$tQz8U|wG4n_-O!hUfe4}$ zT{xYvnTj{9a>+q!>$9?0^0k4$F5GK`+Td~w?6k_4SOMM;d<TegfD*hRcg|-qGK&+A z17nvAhlUCIGAZ9dVu-`StL?pTZnVcE$48+!4!*{i&BP6CF_9jG@g}K?E!{avNmQfQ z>?%$KrxLjH1xeTm_Tsn$llTc)wOCQC66LJL$zh$#{m{QG681i2eXaAZx$i4*Z#K~o zqBX6vf|w2p-Og>>C;D1-lM-C_R~K-vgNs5jL#6bvR|#*ExIkhox1r&ZP%T7SuJ4vW zT;WkyJ!=xoa~T32ZOcX2lzBMC2n@XOJ&%Nfh~osl2n@#On4pofEI^;@UTxOCyv<Nb z^xe7K3Qr&zK|&0Yj2V|l_)2>~L4XZk1MLD(d;|<)?oi;^5Kr~Bkgcy40UfMuLi<%* zBtY;3QvrL5GD@oU2qqG7CXvo5;Q*Gvr!HQijGD7h`dU6xB5W&>z)O4?J;`lq#Qz<K zM;=kk5Nx^=P~c2AM(#<7<`(4|OahbDhBx<Ma>D}i>jTvYL0|3=`s8M+#iNTK93Lr$ z(|h2IIJXl}NF?JrIWG0I#wC}V6NEiQ=$h>%MXd78APyn$A87Dx_%1=u{cWtBZ&E>F z`yQjx^l1l<9~2jHlFJrAv#{@+bX<JhXn%b<31Ju|jZ4aaZe1_JNsO)n!rw<(SN=~n z%*s(`n^0UrodotM)^6kf?n3lsDx|$}Cpv|2>??kcvk|d&$VWo^k*S${RRk$(L{}5x zNf?QE5|M1@v^ak5GAMGLU25z*t$e|`eIR0|9r_a|ggbRLhrYr(8{S5>x0nun)ojxX zQ)(1_$pSa9G){QN<l`iBpGgb$2p&vrs-G&pYRc%0Q^Clj2dqP7;Y5O+`2Jk2FL$m} zWQY@vZ%T<QU)=OJF9)tr!sa9&&-|xt^L1y0EpT42O>h9X;D@k3AU6mFxrJoNa>*k_ z3c(j@R@6{Xr;l=pwqL0qV{aQk0J1u<M;hl~`05|u!s;7sIP>fcHZf`Sd_?P-yq4T} zygOg@NYM@$JBhM}67jV$`I9qAxp%pG@Xv#P9{ls*p9lXu_~*et|DXTa?Y~!c{aG8g zJZom-x}EFRY~H?o?TV*w+PZc7ikU4N*RIgtSDby;`dfDH+`i2}Sif^yz2fW}H=T8Q z|HI)g!|uO4U2i`72ZQaiXyZE<O(wr1`UBCQiT+yjInmcd-xDocJeeFKI!1JgDDYn= z6<sX4O7v9G7ST@83q(IBdX4DyqTdv~Tl7KEM@63y{hjD5qVI^7ESXFW5*;ZzQFOZK z4ABLm$BC{LZ5BOK^j}0T7QIUJOQN@k-XZ#c=p&+!i#{XzqUfJRlf5RB{Y8h1ju)LO zDxz~mj}bjdv_Z5@^c>Moi*6VFqUcveZx`Jm`jF^u(I-WppZ#yDeqXfD(#hmd(Xpac zqQrkERdlK73H+B-ML!{WmgrW|ZKBtT-Y9yT=)I!f7u_ZLE74~~U*(;PmL0Na>7#b+ zSofSoi|%bLU%q^@Xurv#4U<LtFIx27rQSTX)-2QiFLLu~G#9)1YMM*j{LnK0m+ff& z>oRi}%~Q4gi<Y^0J<Yw{d=<@o-26kD`?~oZn)|uAdLKr0^QklsaPyTk4|MYnXddL| zw`neS^AY>1d9a&Lp?Qd#ub}x5H-Dezp>F;Q&BNSWwV#>~b@Mu!hr4+@&4;=9do+)5 z^Pg!R>E_D))jZ10YiS<s=F4dw<K_oxKHSZ3(LC18Qw~t`I5(e6bH>e=(LCPG|3!0! zo8P2)f}1BFsOE`oUPJRFH*cePvYU6(JjKm#&|K-}Ne8L9%FQRye1w}nPjj`KAE0@v zn_s87#?2F#t9hE6Po#Oen?Faha`XK(Yd60}Gq`!e!D>b~ucn#Yd@0Sw&EKV&-TW%e z;^vA&)NI{+0?p3Nm(V=J%{yqG>E=JtJj>1FAEM@3Hy=;)Y&Ty_^BgyShvp;Q{0hxS zxjA#Fn&-NC70vV9{8^gkyZJtv7r6Olnislx++k{7<mQz$FLv{1XkOyxdud+k=9g$* z=H{^vRrAqqUP1FQZvHgQ$GZ6*nwPuzMVgOu^Wlf9d4-#gqj{y9KSlE@H{VV3@os*B z<`djJ=3#1H?dIh)pXla`Xg<l!chS7Y&3~l%WH*mKLd|R4d@RlD+`N_MQ`~$f&8NEg zd79U|dDM|=KF!U?&|K%{3u&%L<S%`Pn(q^RO!QBp{g0XzJIgL#|BOu=b}m}{gXX~p zAM7rV&?A-TGSOzyPY=5+8Fl$BJ@QV`pNYOG+UMv&m%T<^PSGQ4L>G%Th;AKrSvu<S zdOh-Mq7RBbDf;fP%d%0I<ByRh6P+u1is*UA47%(+>hg<v<n^LEME8ikHSDs_sLSCG zm(COw(Uqc`9zN)@@2Jb|dgL{tw~PKn^o3!U{YG8(IaV4}v`TcoX#KH+F8hzV+^R=j zEPA8p{i44ab~#|w<=^$l(&HwR8PS=dYmOUqIdIfvmmYb(=yjrZivD8Q<)BfQuj`R- ziw>C)7l<yK8FX1b>hcqM<e8$|L~jv&XxQc8@hE!a+oFdYKbf2+di3#wE{BXq(Id|k z-6ndA=tILU4;gj&q8|C0X#W-BHPHnt23-yvb=jy#o+0`f(Hlf}4!ayS>hc*q@;TAu z1o4{aj1vZ39y;oBjUKsP^c>M^MDG}OIegURV|wJTMBfq}e4<wE#6g#bjk-Kpk33EE zJke`K?;3VFV$|gmdgN20?}!dNNp|K*gDyvox?HVCt`j|5^lH&>54#*S>hkA$<Q~!2 zMF*ZdnXEo}(B<e+mn-zh6Gb~jFBiRa*yWf}mp{=XcZ<Fx+WVBr<fKyuT^>H_a)BPX zOte|_BGK!IU5*`(qDSr)eOa{6%E{#9m4hzFjk;W-M=lpVL-ezvHx0YYjJkYSkK85t zf@tX~+3BkWU5+1hIZuyVBHAE&f#{cqT~>^`d_a%<f#@@$?}?6j#GuOwqb_IYkw=QI z6+K(@--caI9Cdk@9=StwkLVksLsk#EoHXjv=#eu;SBrLtUODV?@~F$(^~k$LcZ<Fv zI^fhnms3VvDm{`#SBP#D-8Ss9a@6HF^~i6FJ}UZ0(cWtYT~>{{1U=G<t`cn*y?of^ z5u+||(<AQ?-6i^>Xy4NYT~?2}tkEM;^jOg|L@yn7Id#<KEqdg)L?01-PPEtQgDz`E zT~5~{jp%Wrt)ibFb~$a-<u~-m+eLpY`Ula{YS88MQJ0hS$ZFArqV=L%hh3^smpAK? zw~0P1`mAV4J?K)8x~$M6D@Estt`|Lj*d>g*{F)wltLTqJe=k}b23_LV?9n5qh|U!~ zRrHg?E@{-|O?u=vM1LsyThSyAx-_FM$LW!iMCXXE6+L&@C6A3OJ@R_d9imT&{$<#u zjJiBDO(sW+vgk_DGt;0;JL>W(J@N~pcZmK>^iRVs-KfifjUEx5Cc0F#r5SWNW7Op( zdgSGzUl;wM=(EEvXO6lo$vRe|6Ge{{U7rVC&Kh-jksf)8=vPE{iatH;vUb$v`+8(a znM{rqoguoW47!{>HsSQh^F^-{y-W1*VV848UH(~*d{1<ED+MmPq8)U3<fzL{dgNK6 zSBl;y`slFBqefl6q({CkI-t|J5na>`x|};U;q=HeMYoCGBKo6Ym-9wl{y~p?S+w^V zvadwvo-ych{;113J#vHSMWSC8y#clcN%?=+<$_U{zttn37cD+hdm~zV=Ag@kqb}F! zk@cdV6unOL-eH%E#>SN%`IP88qQlP8IX-L9<>FD7EA_~eL^q3W7yZ_-%O#^Of1yYI zx9FRq<!g0r)(*N{I_mNmJ#v+3o9O36zdr18+1Mb_BX^0uAX<91&du3_E{`4?Bzoi$ z(MHh=MgL>i<uRi!zpqC=BKoXoa?WIO+&P0Tj~#V6TaTPCx?c1=(Jv0WTt4dZK0R`$ z=&wcpB6{c}2VEXF>XP)x8KTFFZW7%->~h7}?9n54i0%=6Lv+Za23@Wk8zg!pi>?se zD7tOf<*KpSqetE?x?A)W(E;ZUx;%c=WwjouMUNIeUG(B%mnV!BpB{Ou=#NByFIs%w zpv%>xE+^}eQ$-hvHi%v{?DE7>mpAB<H;aBx^l8!ehh3gD>T=BalgSFvTG2J4UFQ$F zTr=wOT0QbhqW6eCCi=#(%acc4j<`T#Lez<#AliAspv$$RF0a-juM@pf^yi|l4!c}8 z>T>vn@+U<_bd_kwg@Z0n8FhK39(k?ke~RuBeP!6?siQ6jTqG}Cv_^D^=;;>?x?Df% za+@A`mFR7vkBI(p*yU-XE_+`rPfxT`biQcA#e**E#_Cm%yhQXXqB}*O9(GwjR<C+w z$tBtw(HWv^E*W&$FjlX6<oTjs5WQ3Mv0;~uyLUOzK>l()v-mL3{iTO2TC!pLR=4+> z41TlM)-BsM{qSEc+rD}8&6{@q@Lw+7x&0?LZM*kxpw&}{CH63{aYr3@ANYWcn>Oo3 zYi?Y(VaN8l=5XMA=P>Lz`1qN*20m!M0}ng?xU0T=z5@?C?mqCoTJ@WE?zm;c&bcOV z#C#_(?D*p@`H}M-c-V3Gf%n?B?#4}Xjs5WXjy>%7<9_t9^Bs8DaWL>{a}9jld<PzO z{Bgf{X1)UtJMKR4vdvpIZQXeDT%(^n-_eI12cNxau7OXP@4&;3gMs&(zxEgj>fHxk zId$O0Gjs0r;&~7Kh^a##xZ=VsJ8s@N^Ju;9v=s{wsB_GsERfR=p7+S@bXH&S?Cm=? z&iUbo&wKc@7x>{1oA=1)Oy{|}T7VLnW9UacaOZ4z5OyE<+z0ZUO&|LFsY4&M;;Ky> zwr|_GhX-vMyHB6SmD3gY%*@<taM-*DzxqGotQ|G);jdfZSvz{(BR^&8$orgd`i@OE zY}$4DToX89-V@mLz@4}yQwQGsK%ThiLqB~E&Gz`GZ`rY@2X2~Xn?8$Mrp{vN%tBAx z^wFRDK%cm&!!Lf}9FFlq_-@#1_mOX%KJo$?Z~E9jHOJU<tJdMK_I&K0nPbK0{OqOk z9{Oje5526eR@c>*xyIjr-s9i4&`&>L-b24^j!$2`W!vV{=G^s%%zOM-FZ9z7o%hiH zb^6c;_MhJWd(O?D;;_y!jW;ZG1&*Kh&~Kb;^S7<rHuvUFaa!jX|1Ass^r82;=R^Pc zT$}Gt@BcmL<~Q@6#=9RtH8YflyN~>y2UN{WANzgN$KIztJ**bZx$gVTdj=m|DCbQR z_S1*{z3D^mS68Q@Z}#BxA3E<jd~~6oKMgjRKJ=eXA9`Q!eYFRNZVEOz#}w{)01w@= zsUv^l0X=ln$NsB@hI*FFd+5KOKJ=2Uo8}BS3<ucr!9TT7Uf+A(Lw|aqOTN#%hyKh$ zhu(MIL;s)YLoX%NGA9H-CA2oj@Sj`geoyn5rw{!P3tjYS=-Bk3KR?G2yK&u33$di9 z5B|l4F8MT=VEWKsTIiBbQ=-#{{_-5w^VW4YuHU$BA<*3P@xQUqRX=9lLw|Fjt3D-^ zI>*r8nq$>(e$I{Sw{Kkt9yxvd@6Pe*bH?~iocGY*Tj++LH1DDRZJ`@JC8RpX(BGe9 z!*AHMO?y7q_@~Z${3X*fRp#FCHS->NuZ0eM+PsHeI>*p+^4jV19(vjIq4zL`Kg}nf zKK=m<UG+Tgp$}Z>(8Fl-o)3M{978X}DH>YPyN|ql`pEmt%>G%3u{?bS51ZrL7i26? zANq(nn0?REv8I`<)5kw{q33*>$vS=L;}*K=hs=BEnK@Q{&veSP42J3BpS;j>J|+Kd zj-gLk=+M)WC#Da*@&Obv!^6M($gBPnM9lOV)DNVHnLc!wKJ>oUr)$>jxM3ktp6OFK zbD>gZnr}LN=(85O@Y8(L=|ivm50Ns{V%XEiKX0K&eVT7NedzNSI`lN(bo$U2EOh8; fzUlO#FMI$6-0=MGKJrC#jr{)r83#_++P(k)K0uLg From 11a6d4523e97baf1803964e0eec34168ddf231c9 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 13:47:27 +0100 Subject: [PATCH 091/109] add ranged vector->list, string->vector and vector->string #137 --- CHANGELOG.md | 1 + dist/std.min.scm | 6 ++-- dist/std.scm | 81 ++++++++++++++++++++++++++++++++++++++---------- lib/R7RS.scm | 81 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 135 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 005c4af6..2ecd26fc 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * add gensym literals (e.g. `#:foo`) * fix pretty print of different cases of `let` * add binary input/output procedures from R7RS +* update vector functions that in R7RS get start and end arguments ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/dist/std.min.scm b/dist/std.min.scm index c4fba2d2..49dd478d 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -265,6 +265,10 @@ (define (values-ref values n) "(values-ref values n)\u000A\u000AFunction return n value of values object which is result of value function." (typecheck "values-ref" values "values" 1) (typecheck "values-ref" n "number" 1) (--> values (valueOf) n)) (define-syntax let-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ (((x ...) values) ...) body ...) (apply (lambda (x ... ...) body ...) (vector->list (apply vector-append (map (lambda (x) ((. x "valueOf"))) (list values ...))))))) "(let-values binding body ...)\u000A\u000AThe macro work similar to let but variable is list of values and value\u000Aneed to evaluate to result of calling values.") (define (vector-append . args) "(vector-append v1 v2 ...)\u000A\u000AFunction return new vector by combining it's arguments that should be vectors." (if (null? args) (vector) (begin (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args))))))) +(define-macro (%range-function spec . body) "(%range-function spec . body)\u000A\u000AMacro that creates R7RS vector functions that have range start end." (let* ((name (car spec)) (name-str (symbol->string name)) (args (append (cdr spec) (quote rest)))) (quasiquote (define ((unquote name) (unquote-splicing args)) (unquote (if (string? (car body)) (car body))) (let ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (. (unquote (car args)) (quote length)) (cadr rest)))) (typecheck (unquote name-str) start "number") (typecheck (unquote name-str) end "number") (unquote-splicing (if (string? (car body)) (cdr body) body))))))) +(%range-function (vector->list vector) "(vector->list vector)\u000A(vector->list vector start)\u000A(vector->list vector start end)\u000A\u000AFunction copy given range of vector to list. If no start is specified it use\u000Astart of the vector, if no end is specified it convert to the end of the vector." (typecheck "vector->list" vector "array") (array->list (vector.slice start end))) +(%range-function (string->vector string) "(string->list string)\u000A(string->list string start)\u000A(string->list string start end)\u000A\u000AFunction copy given range of string to list. If no start is specified it use\u000Astart of the string, if no end is specified it convert to the end of the string." (typecheck "string->vector" string "string") (--> (string.substring start end) (split "") (map (unary lips.LCharacter)))) +(%range-function (vector->string vector) "(vector->string vector)\u000A(vector->string vector start)\u000A(vector->string vector start end)\u000A\u000AFunction return new string created from vector of characters in given range.\u000AIf no start is given it create string from 0, if no end is given it return\u000Astring to the end." (typecheck "vector->string" vector "array") (--> vector (slice start end) (map (lambda (char.valueOf))) (join ""))) (define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...)\u000A\u000AThe macro work similar to let* but variable is list of values and value\u000Aneed to evaluate to result of calling values.") (define (quotient&remainder x y) (values (quotient x y) (remainder x y))) (define (floor/ x y) (let ((q (quotient x y)) (r (remainder x y))) (if (>= x 0) (if (or (> y 0) (zero? r)) (values q r) (values (- q 1) (+ r y))) (if (and (> y 0) (not (zero? r))) (values (- q 1) (+ r y)) (values q r))))) @@ -282,8 +286,6 @@ (define inexact exact->inexact) (define exact inexact->exact) (define (exact-integer? n) "(exact-integer? n)\u000A\u000AFunction returns #t if z is both exact and an integer; otherwise\u000Areturns #f." (and (integer? n) (exact? n))) -(define (string->vector s) "(string->vector string)\u000A\u000AFunction return vector of characters created from string." (typecheck "string->list" s "string") (--> s (split "") (map (lambda (x) (lips.LCharacter x))))) -(define (vector->string v) "(vector->string vector)\u000A\u000AFunction return new string created from vector of characters." (typecheck "vector->list" v "array") (--> v (map (lambda (char) (char.valueOf))) (join ""))) (define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...)\u000A\u000AFunction return new vector from applying function fn to each element\u000Aof the vectors, similar to map for lists." (if (or (= (length rest) 0) (not (every vector? rest))) (error "vector-map: function require at least 1 vector") (let ((len (apply min (map vector-length rest))) (result (vector))) (do ((i 0 (+ i 1))) ((= i len) result) (let* ((args (map (lambda (v) (vector-ref v i)) rest)) (value (apply fn args))) (--> result (push value))))))) (define (string-map fn . rest) "(string-map fn string1 stringr2 ...)\u000A\u000AFunction return new string from applying function fn to each element\u000Aof the strings, similar to map for lists." (if (or (= (length rest) 0) (not (every string? rest))) (error "string-map: function require at least 1 string") (vector->string (apply vector-map fn (map string->vector rest))))) (define (dynamic-wind before thunk after) "(dynamic-wind before thunk after)\u000A\u000AFunction accept 3 procedures/lambdas and execute thunk with before and always\u000Aafter even if error accur" (before) (let ((result (try (thunk) (catch (e) (error e))))) (after) result)) diff --git a/dist/std.scm b/dist/std.scm index 077702f2..923dd7b9 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3002,6 +3002,71 @@ (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args))))))) +;; ----------------------------------------------------------------------------- +(define-macro (%range-function spec . body) + "(%range-function spec . body) + + Macro that creates R7RS vector functions that have range start end." + (let* ((name (car spec)) + (name-str (symbol->string name)) + (args (append (cdr spec) 'rest))) + `(define (,name ,@args) + ,(if (string? (car body)) + (car body)) + (let ((start (if (null? rest) 0 (car rest))) + (end (if (or (null? rest) (null? (cdr rest))) + (. ,(car args) 'length) + (cadr rest)))) + (typecheck ,name-str start "number") + (typecheck ,name-str end "number") + ,@(if (string? (car body)) + (cdr body) + body))))) + +;; ----------------------------------------------------------------------------- +(%range-function + (vector->list vector) + "(vector->list vector) + (vector->list vector start) + (vector->list vector start end) + + Function copy given range of vector to list. If no start is specified it use + start of the vector, if no end is specified it convert to the end of the vector." + (typecheck "vector->list" vector "array") + (array->list (vector.slice start end))) + +;; ----------------------------------------------------------------------------- + +;; ----------------------------------------------------------------------------- +(%range-function + (string->vector string) + "(string->list string) + (string->list string start) + (string->list string start end) + + Function copy given range of string to list. If no start is specified it use + start of the string, if no end is specified it convert to the end of the string." + (typecheck "string->vector" string "string") + (--> (string.substring start end) + (split "") + (map (unary lips.LCharacter)))) + +;; ----------------------------------------------------------------------------- +(%range-function + (vector->string vector) + "(vector->string vector) + (vector->string vector start) + (vector->string vector start end) + + Function return new string created from vector of characters in given range. + If no start is given it create string from 0, if no end is given it return + string to the end." + (typecheck "vector->string" vector "array") + (--> vector + (slice start end) + (map (lambda (char.valueOf))) + (join ""))) + ;; ----------------------------------------------------------------------------- (define-syntax let*-values (syntax-rules () @@ -3140,22 +3205,6 @@ returns #f." (and (integer? n) (exact? n))) -;; ----------------------------------------------------------------------------- -(define (string->vector s) - "(string->vector string) - - Function return vector of characters created from string." - (typecheck "string->list" s "string") - (--> s (split "") (map (lambda (x) (lips.LCharacter x))))) - -;; ----------------------------------------------------------------------------- -(define (vector->string v) - "(vector->string vector) - - Function return new string created from vector of characters." - (typecheck "vector->list" v "array") - (--> v (map (lambda (char) (char.valueOf))) (join ""))) - ;; ----------------------------------------------------------------------------- (define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index a9691972..796a97f5 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -74,6 +74,71 @@ (typecheck "vector-append" (car args) "array") (--> (car args) (concat (apply vector-append (cdr args))))))) +;; ----------------------------------------------------------------------------- +(define-macro (%range-function spec . body) + "(%range-function spec . body) + + Macro that creates R7RS vector functions that have range start end." + (let* ((name (car spec)) + (name-str (symbol->string name)) + (args (append (cdr spec) 'rest))) + `(define (,name ,@args) + ,(if (string? (car body)) + (car body)) + (let ((start (if (null? rest) 0 (car rest))) + (end (if (or (null? rest) (null? (cdr rest))) + (. ,(car args) 'length) + (cadr rest)))) + (typecheck ,name-str start "number") + (typecheck ,name-str end "number") + ,@(if (string? (car body)) + (cdr body) + body))))) + +;; ----------------------------------------------------------------------------- +(%range-function + (vector->list vector) + "(vector->list vector) + (vector->list vector start) + (vector->list vector start end) + + Function copy given range of vector to list. If no start is specified it use + start of the vector, if no end is specified it convert to the end of the vector." + (typecheck "vector->list" vector "array") + (array->list (vector.slice start end))) + +;; ----------------------------------------------------------------------------- + +;; ----------------------------------------------------------------------------- +(%range-function + (string->vector string) + "(string->list string) + (string->list string start) + (string->list string start end) + + Function copy given range of string to list. If no start is specified it use + start of the string, if no end is specified it convert to the end of the string." + (typecheck "string->vector" string "string") + (--> (string.substring start end) + (split "") + (map (unary lips.LCharacter)))) + +;; ----------------------------------------------------------------------------- +(%range-function + (vector->string vector) + "(vector->string vector) + (vector->string vector start) + (vector->string vector start end) + + Function return new string created from vector of characters in given range. + If no start is given it create string from 0, if no end is given it return + string to the end." + (typecheck "vector->string" vector "array") + (--> vector + (slice start end) + (map (lambda (char.valueOf))) + (join ""))) + ;; ----------------------------------------------------------------------------- (define-syntax let*-values (syntax-rules () @@ -212,22 +277,6 @@ returns #f." (and (integer? n) (exact? n))) -;; ----------------------------------------------------------------------------- -(define (string->vector s) - "(string->vector string) - - Function return vector of characters created from string." - (typecheck "string->list" s "string") - (--> s (split "") (map (lambda (x) (lips.LCharacter x))))) - -;; ----------------------------------------------------------------------------- -(define (vector->string v) - "(vector->string vector) - - Function return new string created from vector of characters." - (typecheck "vector->list" v "array") - (--> v (map (lambda (char) (char.valueOf))) (join ""))) - ;; ----------------------------------------------------------------------------- (define (vector-map fn . rest) "(vector-map fn vector1 vector2 ...) From 3f0125257f29b59ece4c80f7f186a4b6bdd17992 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 14:13:53 +0100 Subject: [PATCH 092/109] fix `in` and `repr` of vectors + `vector-fill!` with rage #137 --- CHANGELOG.md | 1 + README.md | 2 +- dist/lips.js | 12 ++++++------ dist/lips.min.js | 4 ++-- dist/std.min.scm | 3 ++- dist/std.scm | 31 ++++++++++++++++++++++++++----- lib/R5RS.scm | 13 ++++++++++--- lib/R7RS.scm | 18 ++++++++++++++++-- src/lips.js | 6 ++++-- 9 files changed, 68 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ecd26fc..693c161f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ * fix complex operation that result in real (e.g. multiplication over conjugation) * fix `list-ref` according to R7RS errata * fix formatter (pretty print) on multiline strings and atoms +* fix repr of vectors (arrays with empty value) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 91cc2022..2b4e4d84 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&c42e3ec54ca2e2a2bf65240e00bbd03b32a3583f)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&11a6d4523e97baf1803964e0eec34168ddf231c9)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&37d92ca40f03da1d26598c0ee49db9a2)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index fa6fdd16..20fb6ec3 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 12:25:17 +0000 + * build: Sun, 07 Mar 2021 13:06:05 +0000 */ (function () { 'use strict'; @@ -11749,11 +11749,11 @@ }, "(debugger)\n\n Function stop JavaScript code in debugger."), // ------------------------------------------------------------------ 'in': doc('in', function (a, b) { - if (a instanceof LSymbol || a instanceof LString) { + if (a instanceof LSymbol || a instanceof LString || a instanceof LNumber) { a = a.valueOf(); } - return a in b; + return a in unbox(b); }, "(in key value)\n\n Function use is in operator to check if value is in object."), // ------------------------------------------------------------------ 'instanceof': doc('instanceof', function (type, obj) { @@ -13699,10 +13699,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 07 Mar 2021 12:25:17 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 07 Mar 2021 13:06:05 +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('Sun, 07 Mar 2021 12:25:17 +0000').valueOf(); + var date = LString('Sun, 07 Mar 2021 13:06:05 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13742,7 +13742,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 07 Mar 2021 12:25:17 +0000', + date: 'Sun, 07 Mar 2021 13:06:05 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 9b6769e9..2e3cc0bf 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 12:25:17 +0000 + * build: Sun, 07 Mar 2021 13:06:05 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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=e.valueOf()}return e in 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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 12:25:17 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 12:25:17 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 13:06:05 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 13:06:05 +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/dist/std.min.scm b/dist/std.min.scm index 49dd478d..209b03fe 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -123,7 +123,7 @@ (set-special! "#" (quote vector-literal) lips.specials.SPLICE) (define-macro (vector-literal . args) (if (not (or (pair? args) (eq? args ()))) (throw (new Error (concat "Parse Error: vector require pair got " (type args) " in " (repr args)))) (let ((v (list->array args))) (Object.freeze v) v))) (define-syntax vector (syntax-rules () ((_ arg ...) (list->array (list arg ...)))) "(vector 1 2 3 (+ 3 1))\u000A#(1 2 3 4)\u000A\u000AMacro for defining vectors (JavaScript arrays). Vectors literals are\u000Aautomatically quoted. So you can use expressions inside them. Only other\u000Aliterals, like other vectors or object.") -(set-repr! Array (lambda (x q) (let ((arr (--> x (map (lambda (x) (repr x q)))))) (concat "#(" (--> arr (join " ")) ")")))) +(set-repr! Array (lambda (arr q) (let ((result (--> (Array.from arr) (map (lambda (x i) (if (not (in i arr)) "#<empty>" (repr (. arr i) q))))))) (concat "#(" (--> result (join " ")) ")")))) (define (eqv? a b) "(eqv? a b)\u000A\u000AFunction compare the values. It return true if they are the same, they\u000Aneed to have same type" (if (string=? (type a) (type b)) (cond ((number? a) (or (and (exact? a) (exact? b) (= a b)) (and (inexact? a) (inexact? b) (cond ((a.isNaN) (b.isNaN)) ((and (zero? a) (zero? b)) (eq? a._minus b._minus)) ((and (complex? a) (complex? b)) (let ((re.a (real-part a)) (re.b (real-part b)) (im.a (imag-part a)) (im.b (imag-part b))) (and (if (and (zero? re.a) (zero? re.b)) (eq? (. re.a (quote _minus)) (. re.b (quote _minus))) #t) (if (and (zero? im.a) (zero? im.b)) (eq? (. im.a (quote _minus)) (. im.b (quote _minus))) #t) (or (= re.a re.b) (and (--> re.a (isNaN)) (--> re.b (isNaN)))) (or (= im.a im.b) (and (--> im.a (isNaN)) (--> im.b (isNaN))))))) (else (= a b)))))) ((pair? a) (and (null? a) (null? b))) (else (eq? a b))) #f)) (define (equal? a b) "(equal? a b)\u000A\u000AFunction check if values are equal if both are pair or array\u000Ait compares the their elements recursivly." (cond ((and (pair? a)) (and (pair? b) (equal? (car a) (car b)) (equal? (cdr a) (cdr b)))) ((symbol? a) (and (symbol? b) (equal? a.__name__ b.__name__))) ((regex? a) (and (regex? b) (equal? (. a (quote source)) (. b (quote source))))) ((typed-array? a) (and (typed-array? b) (equal? (Array.from a) (Array.from b)))) ((vector? a) (and (vector? b) (= (length a) (length b)) (--> a (every (lambda (item i) (equal? item (vector-ref b i))))))) ((string? a) (and (string? b) (string=? a b))) ((function? a) (and (function? b) (%same-functions a b))) ((array? a) (and (array? b) (eq? (length a) (length b)) (= (--> a (filter (lambda (item i) (equal? item (. b i)))) (quote length)) (length a)))) ((plain-object? a) (and (plain-object? b) (let ((keys_a (--> (Object.keys a) (sort))) (keys_b (--> (Object.keys b) (sort)))) (and (= (length keys_a) (length keys_b)) (equal? keys_a keys_b) (equal? (--> keys_a (map (lambda (key) (. a key)))) (--> keys_b (map (lambda (key) (. b key))))))))) (else (eqv? a b)))) (define make-promise (lambda (proc) "(make-promise fn)\u000A\u000AFunction create promise from a function." (typecheck "make-promise" proc "function") (let ((result-ready? #f) (result #f)) (let ((promise (lambda () (if result-ready? result (let ((x (proc))) (if result-ready? result (begin (set! result-ready? #t) (set! result x) result))))))) (set-obj! promise (Symbol.for "promise") #t) (set! promise.toString (lambda () (string-append "#<promise - " (if result-ready? (string-append "forced with " (type result)) "not forced") ">"))) promise)))) @@ -269,6 +269,7 @@ (%range-function (vector->list vector) "(vector->list vector)\u000A(vector->list vector start)\u000A(vector->list vector start end)\u000A\u000AFunction copy given range of vector to list. If no start is specified it use\u000Astart of the vector, if no end is specified it convert to the end of the vector." (typecheck "vector->list" vector "array") (array->list (vector.slice start end))) (%range-function (string->vector string) "(string->list string)\u000A(string->list string start)\u000A(string->list string start end)\u000A\u000AFunction copy given range of string to list. If no start is specified it use\u000Astart of the string, if no end is specified it convert to the end of the string." (typecheck "string->vector" string "string") (--> (string.substring start end) (split "") (map (unary lips.LCharacter)))) (%range-function (vector->string vector) "(vector->string vector)\u000A(vector->string vector start)\u000A(vector->string vector start end)\u000A\u000AFunction return new string created from vector of characters in given range.\u000AIf no start is given it create string from 0, if no end is given it return\u000Astring to the end." (typecheck "vector->string" vector "array") (--> vector (slice start end) (map (lambda (char.valueOf))) (join ""))) +(%range-function (vector-fill! vector fill) "(vector-fill! vector fill)\u000A(vector-fill! vector fill start)\u000A(vector-fill! vector fill start end)\u000A\u000AFill vector with a given value in given range. If start is not given is start\u000Aat 0. If end is not given it fill till the end if the vector." (typecheck "vector->fill!" vector "array") (let recur ((n (- end start))) (if (>= n start) (begin (set-obj! vector n fill) (recur (- n 1)))))) (define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...)\u000A\u000AThe macro work similar to let* but variable is list of values and value\u000Aneed to evaluate to result of calling values.") (define (quotient&remainder x y) (values (quotient x y) (remainder x y))) (define (floor/ x y) (let ((q (quotient x y)) (r (remainder x y))) (if (>= x 0) (if (or (> y 0) (zero? r)) (values q r) (values (- q 1) (+ r y))) (if (and (> y 0) (not (zero? r))) (values (- q 1) (+ r y)) (values q r))))) diff --git a/dist/std.scm b/dist/std.scm index 923dd7b9..80fdc88d 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1455,9 +1455,16 @@ ;; ----------------------------------------------------------------------------- (set-repr! Array - (lambda (x q) - (let ((arr (--> x (map (lambda (x) (repr x q)))))) - (concat "#(" (--> arr (join " ")) ")")))) + (lambda (arr q) + ;; Array.from is used to convert emtpy to undefined + ;; but we can't use the value because Array.from call + ;; valueOf on its arguments + (let ((result (--> (Array.from arr) + (map (lambda (x i) + (if (not (in i arr)) + "#<empty>" + (repr (. arr i) q))))))) + (concat "#(" (--> result (join " ")) ")")))) ;; ----------------------------------------------------------------------------- (define (eqv? a b) @@ -3035,8 +3042,6 @@ (typecheck "vector->list" vector "array") (array->list (vector.slice start end))) -;; ----------------------------------------------------------------------------- - ;; ----------------------------------------------------------------------------- (%range-function (string->vector string) @@ -3067,6 +3072,22 @@ (map (lambda (char.valueOf))) (join ""))) +;; ----------------------------------------------------------------------------- +(%range-function + (vector-fill! vector fill) + "(vector-fill! vector fill) + (vector-fill! vector fill start) + (vector-fill! vector fill start end) + + Fill vector with a given value in given range. If start is not given is start + at 0. If end is not given it fill till the end if the vector." + (typecheck "vector->fill!" vector "array") + (let recur ((n (- end start))) + (if (>= n start) + (begin + (set-obj! vector n fill) + (recur (- n 1)))))) + ;; ----------------------------------------------------------------------------- (define-syntax let*-values (syntax-rules () diff --git a/lib/R5RS.scm b/lib/R5RS.scm index 7cb2aab7..b5caa0ed 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -74,9 +74,16 @@ ;; ----------------------------------------------------------------------------- (set-repr! Array - (lambda (x q) - (let ((arr (--> x (map (lambda (x) (repr x q)))))) - (concat "#(" (--> arr (join " ")) ")")))) + (lambda (arr q) + ;; Array.from is used to convert emtpy to undefined + ;; but we can't use the value because Array.from call + ;; valueOf on its arguments + (let ((result (--> (Array.from arr) + (map (lambda (x i) + (if (not (in i arr)) + "#<empty>" + (repr (. arr i) q))))))) + (concat "#(" (--> result (join " ")) ")")))) ;; ----------------------------------------------------------------------------- (define (eqv? a b) diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 796a97f5..abda32ff 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -107,8 +107,6 @@ (typecheck "vector->list" vector "array") (array->list (vector.slice start end))) -;; ----------------------------------------------------------------------------- - ;; ----------------------------------------------------------------------------- (%range-function (string->vector string) @@ -139,6 +137,22 @@ (map (lambda (char.valueOf))) (join ""))) +;; ----------------------------------------------------------------------------- +(%range-function + (vector-fill! vector fill) + "(vector-fill! vector fill) + (vector-fill! vector fill start) + (vector-fill! vector fill start end) + + Fill vector with a given value in given range. If start is not given is start + at 0. If end is not given it fill till the end if the vector." + (typecheck "vector->fill!" vector "array") + (let recur ((n (- end start))) + (if (>= n start) + (begin + (set-obj! vector n fill) + (recur (- n 1)))))) + ;; ----------------------------------------------------------------------------- (define-syntax let*-values (syntax-rules () diff --git a/src/lips.js b/src/lips.js index 88aadf0f..9a84d374 100644 --- a/src/lips.js +++ b/src/lips.js @@ -8009,10 +8009,12 @@ Function stop JavaScript code in debugger.`), // ------------------------------------------------------------------ 'in': doc('in', function(a, b) { - if (a instanceof LSymbol || a instanceof LString) { + if (a instanceof LSymbol || + a instanceof LString || + a instanceof LNumber) { a = a.valueOf(); } - return a in b; + return a in unbox(b); }, `(in key value) Function use is in operator to check if value is in object.`), From dc24ef7fc7d09f65da5d5ae4d8623fc9a4c83a95 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 14:24:00 +0100 Subject: [PATCH 093/109] fix broken vector->string #137 --- dist/std.min.scm | 2 +- dist/std.scm | 2 +- lib/R7RS.scm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index 209b03fe..981408fd 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -268,7 +268,7 @@ (define-macro (%range-function spec . body) "(%range-function spec . body)\u000A\u000AMacro that creates R7RS vector functions that have range start end." (let* ((name (car spec)) (name-str (symbol->string name)) (args (append (cdr spec) (quote rest)))) (quasiquote (define ((unquote name) (unquote-splicing args)) (unquote (if (string? (car body)) (car body))) (let ((start (if (null? rest) 0 (car rest))) (end (if (or (null? rest) (null? (cdr rest))) (. (unquote (car args)) (quote length)) (cadr rest)))) (typecheck (unquote name-str) start "number") (typecheck (unquote name-str) end "number") (unquote-splicing (if (string? (car body)) (cdr body) body))))))) (%range-function (vector->list vector) "(vector->list vector)\u000A(vector->list vector start)\u000A(vector->list vector start end)\u000A\u000AFunction copy given range of vector to list. If no start is specified it use\u000Astart of the vector, if no end is specified it convert to the end of the vector." (typecheck "vector->list" vector "array") (array->list (vector.slice start end))) (%range-function (string->vector string) "(string->list string)\u000A(string->list string start)\u000A(string->list string start end)\u000A\u000AFunction copy given range of string to list. If no start is specified it use\u000Astart of the string, if no end is specified it convert to the end of the string." (typecheck "string->vector" string "string") (--> (string.substring start end) (split "") (map (unary lips.LCharacter)))) -(%range-function (vector->string vector) "(vector->string vector)\u000A(vector->string vector start)\u000A(vector->string vector start end)\u000A\u000AFunction return new string created from vector of characters in given range.\u000AIf no start is given it create string from 0, if no end is given it return\u000Astring to the end." (typecheck "vector->string" vector "array") (--> vector (slice start end) (map (lambda (char.valueOf))) (join ""))) +(%range-function (vector->string vector) "(vector->string vector)\u000A(vector->string vector start)\u000A(vector->string vector start end)\u000A\u000AFunction return new string created from vector of characters in given range.\u000AIf no start is given it create string from 0, if no end is given it return\u000Astring to the end." (typecheck "vector->string" vector "array") (--> vector (slice start end) (map (lambda (char) (char.valueOf))) (join ""))) (%range-function (vector-fill! vector fill) "(vector-fill! vector fill)\u000A(vector-fill! vector fill start)\u000A(vector-fill! vector fill start end)\u000A\u000AFill vector with a given value in given range. If start is not given is start\u000Aat 0. If end is not given it fill till the end if the vector." (typecheck "vector->fill!" vector "array") (let recur ((n (- end start))) (if (>= n start) (begin (set-obj! vector n fill) (recur (- n 1)))))) (define-syntax let*-values (syntax-rules () ((_ ()) ()) ((_ () body ...) (begin body ...)) ((_ ((bind values) rest ...) . body) (apply (lambda bind (let*-values (rest ...) . body)) (vector->list ((. values "valueOf")))))) "(let*-values binding body ...)\u000A\u000AThe macro work similar to let* but variable is list of values and value\u000Aneed to evaluate to result of calling values.") (define (quotient&remainder x y) (values (quotient x y) (remainder x y))) diff --git a/dist/std.scm b/dist/std.scm index 80fdc88d..d5a28b0e 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -3069,7 +3069,7 @@ (typecheck "vector->string" vector "array") (--> vector (slice start end) - (map (lambda (char.valueOf))) + (map (lambda (char) (char.valueOf))) (join ""))) ;; ----------------------------------------------------------------------------- diff --git a/lib/R7RS.scm b/lib/R7RS.scm index abda32ff..657e36e9 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -134,7 +134,7 @@ (typecheck "vector->string" vector "array") (--> vector (slice start end) - (map (lambda (char.valueOf))) + (map (lambda (char) (char.valueOf))) (join ""))) ;; ----------------------------------------------------------------------------- From add5f015e621618204d2a5ea630b19a4dc679209 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 15:14:55 +0100 Subject: [PATCH 094/109] update UML diagram #132 --- assets/classDiagram | 10 +++++----- assets/classDiagram.svg | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/assets/classDiagram b/assets/classDiagram index 8214a56c..4432675c 100644 --- a/assets/classDiagram +++ b/assets/classDiagram @@ -20,8 +20,8 @@ Formatter *-- Pattern Interpreter *-- Environment class LRational { - LNumber num - LNumber denom + LNumber __num__ + LNumber __denom__ pow() abs() cmp() @@ -34,19 +34,19 @@ class LRational { } class LBigInteger { - BigInt value + BigInt __value__ sqrt() gcd() sqrt() } class LFloat { - Number value + Number __value__ toRational() toString() } class LNumber { - Number value + Number __value__ isFloat() isNumber() isComplex() diff --git a/assets/classDiagram.svg b/assets/classDiagram.svg index c1a48dfe..5877e4ef 100644 --- a/assets/classDiagram.svg +++ b/assets/classDiagram.svg @@ -1 +1 @@ -<svg id="mermaid-1610567067273" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="596" style="max-width: 2735.078125px;" viewBox="-20 -20 2735.078125 596"><style>#mermaid-1610567067273{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1610567067273 .error-icon{fill:#552222;}#mermaid-1610567067273 .error-text{fill:#552222;stroke:#552222;}#mermaid-1610567067273 .edge-thickness-normal{stroke-width:2px;}#mermaid-1610567067273 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1610567067273 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1610567067273 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1610567067273 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1610567067273 .marker{fill:#333333;}#mermaid-1610567067273 .marker.cross{stroke:#333333;}#mermaid-1610567067273 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1610567067273 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1610567067273 g.classGroup text .title{font-weight:bolder;}#mermaid-1610567067273 .classTitle{font-weight:bolder;}#mermaid-1610567067273 .node rect,#mermaid-1610567067273 .node circle,#mermaid-1610567067273 .node ellipse,#mermaid-1610567067273 .node polygon,#mermaid-1610567067273 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1610567067273 .divider{stroke:#9370DB;stroke:1;}#mermaid-1610567067273 g.clickable{cursor:pointer;}#mermaid-1610567067273 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1610567067273 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1610567067273 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1610567067273 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1610567067273 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1610567067273 .dashed-line{stroke-dasharray:3;}#mermaid-1610567067273 #compositionStart,#mermaid-1610567067273 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #compositionEnd,#mermaid-1610567067273 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #dependencyStart,#mermaid-1610567067273 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #dependencyStart,#mermaid-1610567067273 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #extensionStart,#mermaid-1610567067273 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #extensionEnd,#mermaid-1610567067273 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #aggregationStart,#mermaid-1610567067273 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 #aggregationEnd,#mermaid-1610567067273 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1610567067273 .edgeTerminals{font-size:11px;}#mermaid-1610567067273:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1610567067273 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(190.140625,0 )"><rect x="0" y="0" width="77.640625" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.1796875">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="77.640625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number value</tspan></text><line x1="0" y1="37" y2="37" x2="77.640625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="68.328125" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="7.3359375">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="68.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt value</tspan></text><line x1="0" y1="37" y2="37" x2="68.328125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(118.328125,293 )"><rect x="0" y="0" width="88.296875" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.2421875">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="88.296875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber num</tspan><tspan x="5" dy="10">LNumber denom</tspan></text><line x1="0" y1="47" y2="47" x2="88.296875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(256.625,333 )"><rect x="0" y="0" width="77.640625" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="24.1640625">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="77.640625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number value</tspan></text><line x1="0" y1="37" y2="37" x2="77.640625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(384.265625,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(524.6875,40 )"><rect x="0" y="0" width="82.203125" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.2421875">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="82.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Function _read</tspan></text><line x1="0" y1="37" y2="37" x2="82.203125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(525.296875,352 )"><rect x="0" y="0" width="80.984375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="80.984375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="80.984375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(530.171875,526 )"><rect x="0" y="0" width="71.234375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="71.234375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="71.234375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(739.33203125,70.5 )"><rect x="0" y="0" width="61.9375" height="67" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="61.9375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="61.9375"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(656.28125,346.5 )"><rect x="0" y="0" width="89.203125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="89.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] _buffer</tspan></text><line x1="0" y1="37" y2="37" x2="89.203125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(795.484375,341.5 )"><rect x="0" y="0" width="88.46875" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.5078125">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="88.46875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _filename</tspan><tspan x="5" dy="10">number _fd</tspan></text><line x1="0" y1="47" y2="47" x2="88.46875"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Parser-11" class="classGroup" transform="translate(926.1875,83.5 )"><rect x="0" y="0" width="87.375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="28.65625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="87.375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan></text><line x1="0" y1="37" y2="37" x2="87.375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Lexer-12" class="classGroup" transform="translate(933.953125,346.5 )"><rect x="0" y="0" width="71.84375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.1484375">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="71.84375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _input</tspan></text><line x1="0" y1="37" y2="37" x2="71.84375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Macro-13" class="classGroup" transform="translate(1063.5625,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-14" class="classGroup" transform="translate(1093.390625,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-15" class="classGroup" transform="translate(1245.109375,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-16" class="classGroup" transform="translate(1201.390625,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-17" class="classGroup" transform="translate(1377.9921875,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-18" class="classGroup" transform="translate(1382.64453125,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-19" class="classGroup" transform="translate(1471.98828125,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-20" class="classGroup" transform="translate(1601.359375,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-21" class="classGroup" transform="translate(1623.1015625,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-22" class="classGroup" transform="translate(1843.53125,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-23" class="classGroup" transform="translate(2009.78125,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-24" class="classGroup" transform="translate(2149.234375,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-25" class="classGroup" transform="translate(2288.6875,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-26" class="classGroup" transform="translate(2429.5,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-27" class="classGroup" transform="translate(2589.75,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">lastPair()</tspan><tspan x="5" dy="10">toArray()</tspan><tspan x="5" dy="10">toObject()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M190.140625,129.70790887944173L164.14453125,146.92325739953478C138.1484375,164.13860591962782,86.15625,198.56930295981388,60.16015625,231.61798481324027C34.1640625,264.6666666666667,34.1640625,296.3333333333333,34.1640625,312.1666666666667L34.1640625,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M190.140625,179.32326674500587L185.52994791666666,188.26938895417155C180.91927083333334,197.21551116333725,171.69791666666666,215.1077555816686,167.08723958333334,234.05387779083432C162.4765625,253,162.4765625,273,162.4765625,283L162.4765625,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M267.78125,179.32326674500587L272.3919270833333,188.26938895417155C277.0026041666667,197.21551116333725,286.2239583333333,215.1077555816686,290.8346354166667,240.72054445750098C295.4453125,266.3333333333333,295.4453125,299.6666666666667,295.4453125,316.3333333333333L295.4453125,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M267.78125,128.93682163003308L294.78125,146.28068469169423C321.78125,163.6245477533554,375.78125,198.31227387667772,402.78125,223.9894702716722C429.78125,249.66666666666666,429.78125,266.3333333333333,429.78125,274.6666666666667L429.78125,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M565.7890625,168L565.7890625,178.83333333333334C565.7890625,189.66666666666666,565.7890625,211.33333333333334,565.7890625,242C565.7890625,272.6666666666667,565.7890625,312.3333333333333,565.7890625,332.1666666666667L565.7890625,352" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M565.7890625,382L565.7890625,401.8333333333333C565.7890625,421.6666666666667,565.7890625,461.3333333333333,565.7890625,485.3333333333333C565.7890625,509.3333333333333,565.7890625,517.6666666666666,565.7890625,521.8333333333334L565.7890625,526" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M752.2736343265503,137.5L743.7084973554587,153.41666666666666C735.1433603843669,169.33333333333334,718.0130864421835,201.16666666666666,709.4479494710918,236C700.8828125,270.8333333333333,700.8828125,308.6666666666667,700.8828125,327.5833333333333L700.8828125,346.5" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M788.3279281734497,137.5L796.8930651445413,153.41666666666666C805.4582021156331,169.33333333333334,822.5884760578165,201.16666666666666,831.1536130289082,235.16666666666666C839.71875,269.1666666666667,839.71875,305.3333333333333,839.71875,323.4166666666667L839.71875,341.5" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M969.875,124.5L969.875,142.58333333333334C969.875,160.66666666666666,969.875,196.83333333333334,969.875,233.83333333333334C969.875,270.8333333333333,969.875,308.6666666666667,969.875,327.5833333333333L969.875,346.5" id="edge8" class="relation" marker-start="url(#compositionStart)"></path><path d="M1122.390625,158L1122.390625,170.5C1122.390625,183,1122.390625,208,1122.390625,238.08333333333334C1122.390625,268.1666666666667,1122.390625,303.3333333333333,1122.390625,320.9166666666667L1122.390625,338.5" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M1263.7421875,119L1263.7421875,138C1263.7421875,157,1263.7421875,195,1263.7421875,224.83333333333334C1263.7421875,254.66666666666666,1263.7421875,276.3333333333333,1263.7421875,287.1666666666667L1263.7421875,298" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1436.6906492248063,148L1430.961608729005,162.16666666666666C1425.2325682332041,176.33333333333334,1413.7744872416022,204.66666666666666,1408.045446745801,238.66666666666666C1402.31640625,272.6666666666667,1402.31640625,312.3333333333333,1402.31640625,332.1666666666667L1402.31640625,352" id="edge11" class="relation" marker-start="url(#compositionStart)"></path><path d="M1472.2781007751937,148L1478.007141270995,162.16666666666666C1483.7361817667959,176.33333333333334,1495.1942627583978,204.66666666666666,1500.923303254199,236.91666666666666C1506.65234375,269.1666666666667,1506.65234375,305.3333333333333,1506.65234375,323.4166666666667L1506.65234375,341.5" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1697.4453125,148L1697.4453125,162.16666666666666C1697.4453125,176.33333333333334,1697.4453125,204.66666666666666,1697.4453125,223C1697.4453125,241.33333333333334,1697.4453125,249.66666666666666,1697.4453125,253.83333333333334L1697.4453125,258" id="edge13" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file +<svg id="mermaid-1615126461173" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="596" style="max-width: 2799.1875px;" viewBox="-20 -20 2799.1875 596"><style>#mermaid-1615126461173{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1615126461173 .error-icon{fill:#552222;}#mermaid-1615126461173 .error-text{fill:#552222;stroke:#552222;}#mermaid-1615126461173 .edge-thickness-normal{stroke-width:2px;}#mermaid-1615126461173 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1615126461173 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1615126461173 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1615126461173 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1615126461173 .marker{fill:#333333;}#mermaid-1615126461173 .marker.cross{stroke:#333333;}#mermaid-1615126461173 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1615126461173 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1615126461173 g.classGroup text .title{font-weight:bolder;}#mermaid-1615126461173 .classTitle{font-weight:bolder;}#mermaid-1615126461173 .node rect,#mermaid-1615126461173 .node circle,#mermaid-1615126461173 .node ellipse,#mermaid-1615126461173 .node polygon,#mermaid-1615126461173 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1615126461173 .divider{stroke:#9370DB;stroke:1;}#mermaid-1615126461173 g.clickable{cursor:pointer;}#mermaid-1615126461173 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1615126461173 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1615126461173 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1615126461173 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1615126461173 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1615126461173 .dashed-line{stroke-dasharray:3;}#mermaid-1615126461173 #compositionStart,#mermaid-1615126461173 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #compositionEnd,#mermaid-1615126461173 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #dependencyStart,#mermaid-1615126461173 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #dependencyStart,#mermaid-1615126461173 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #extensionStart,#mermaid-1615126461173 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #extensionEnd,#mermaid-1615126461173 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #aggregationStart,#mermaid-1615126461173 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #aggregationEnd,#mermaid-1615126461173 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 .edgeTerminals{font-size:11px;}#mermaid-1615126461173:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1615126461173 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(222.33203125,0 )"><rect x="0" y="0" width="98.828125" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="27.7734375">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="89.515625" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.9296875">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="89.515625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt __value__</tspan></text><line x1="0" y1="37" y2="37" x2="89.515625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(139.515625,293 )"><rect x="0" y="0" width="110.03125" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="33.109375">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="110.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __num__</tspan><tspan x="5" dy="10">LNumber __denom__</tspan></text><line x1="0" y1="47" y2="47" x2="110.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(299.546875,333 )"><rect x="0" y="0" width="98.828125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="34.7578125">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(448.375,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(588.796875,40 )"><rect x="0" y="0" width="82.203125" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.2421875">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="82.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Function _read</tspan></text><line x1="0" y1="37" y2="37" x2="82.203125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(589.40625,352 )"><rect x="0" y="0" width="80.984375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="80.984375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="80.984375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(594.28125,526 )"><rect x="0" y="0" width="71.234375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="71.234375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="71.234375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(803.44140625,70.5 )"><rect x="0" y="0" width="61.9375" height="67" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="61.9375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="61.9375"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(720.390625,346.5 )"><rect x="0" y="0" width="89.203125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="89.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] _buffer</tspan></text><line x1="0" y1="37" y2="37" x2="89.203125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(859.59375,341.5 )"><rect x="0" y="0" width="88.46875" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.5078125">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="88.46875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _filename</tspan><tspan x="5" dy="10">number _fd</tspan></text><line x1="0" y1="47" y2="47" x2="88.46875"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Parser-11" class="classGroup" transform="translate(990.296875,83.5 )"><rect x="0" y="0" width="87.375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="28.65625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="87.375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan></text><line x1="0" y1="37" y2="37" x2="87.375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Lexer-12" class="classGroup" transform="translate(998.0625,346.5 )"><rect x="0" y="0" width="71.84375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.1484375">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="71.84375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _input</tspan></text><line x1="0" y1="37" y2="37" x2="71.84375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Macro-13" class="classGroup" transform="translate(1127.671875,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-14" class="classGroup" transform="translate(1157.5,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-15" class="classGroup" transform="translate(1309.21875,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-16" class="classGroup" transform="translate(1265.5,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-17" class="classGroup" transform="translate(1442.1015625,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-18" class="classGroup" transform="translate(1446.75390625,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-19" class="classGroup" transform="translate(1536.09765625,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-20" class="classGroup" transform="translate(1665.46875,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-21" class="classGroup" transform="translate(1687.2109375,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-22" class="classGroup" transform="translate(1907.640625,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-23" class="classGroup" transform="translate(2073.890625,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-24" class="classGroup" transform="translate(2213.34375,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-25" class="classGroup" transform="translate(2352.796875,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-26" class="classGroup" transform="translate(2493.609375,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-27" class="classGroup" transform="translate(2653.859375,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">lastPair()</tspan><tspan x="5" dy="10">toArray()</tspan><tspan x="5" dy="10">toObject()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M222.33203125,132.08256896522053L192.736328125,148.90214080435044C163.140625,165.72171264348034,103.94921875,199.36085632174016,74.353515625,232.01376149420344C44.7578125,264.6666666666667,44.7578125,296.3333333333333,44.7578125,312.1666666666667L44.7578125,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M222.33203125,186.55425709515862L217.69856770833334,194.29521424596552C213.06510416666666,202.0361713967724,203.79817708333334,217.51808569838622,199.16471354166666,235.2590428491931C194.53125,253,194.53125,273,194.53125,283L194.53125,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,186.55425709515862L325.7936197916667,194.29521424596552C330.4270833333333,202.0361713967724,339.6940104166667,217.51808569838622,344.3274739583333,241.92570951585978C348.9609375,266.3333333333333,348.9609375,299.6666666666667,348.9609375,316.3333333333333L348.9609375,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,132.69489528565651L349.9485677083333,149.4124127380471C378.7369791666667,166.12993019043768,436.3138020833333,199.5649650952188,465.1022135416667,224.61581588094273C493.890625,249.66666666666666,493.890625,266.3333333333333,493.890625,274.6666666666667L493.890625,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,168L629.8984375,178.83333333333334C629.8984375,189.66666666666666,629.8984375,211.33333333333334,629.8984375,242C629.8984375,272.6666666666667,629.8984375,312.3333333333333,629.8984375,332.1666666666667L629.8984375,352" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,382L629.8984375,401.8333333333333C629.8984375,421.6666666666667,629.8984375,461.3333333333333,629.8984375,485.3333333333333C629.8984375,509.3333333333333,629.8984375,517.6666666666666,629.8984375,521.8333333333334L629.8984375,526" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M816.3830093265503,137.5L807.8178723554587,153.41666666666666C799.2527353843669,169.33333333333334,782.1224614421835,201.16666666666666,773.5573244710918,236C764.9921875,270.8333333333333,764.9921875,308.6666666666667,764.9921875,327.5833333333333L764.9921875,346.5" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M852.4373031734497,137.5L861.0024401445413,153.41666666666666C869.5675771156331,169.33333333333334,886.6978510578165,201.16666666666666,895.2629880289082,235.16666666666666C903.828125,269.1666666666667,903.828125,305.3333333333333,903.828125,323.4166666666667L903.828125,341.5" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M1033.984375,124.5L1033.984375,142.58333333333334C1033.984375,160.66666666666666,1033.984375,196.83333333333334,1033.984375,233.83333333333334C1033.984375,270.8333333333333,1033.984375,308.6666666666667,1033.984375,327.5833333333333L1033.984375,346.5" id="edge8" class="relation" marker-start="url(#compositionStart)"></path><path d="M1186.5,158L1186.5,170.5C1186.5,183,1186.5,208,1186.5,238.08333333333334C1186.5,268.1666666666667,1186.5,303.3333333333333,1186.5,320.9166666666667L1186.5,338.5" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M1327.8515625,119L1327.8515625,138C1327.8515625,157,1327.8515625,195,1327.8515625,224.83333333333334C1327.8515625,254.66666666666666,1327.8515625,276.3333333333333,1327.8515625,287.1666666666667L1327.8515625,298" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1500.8000242248063,148L1495.070983729005,162.16666666666666C1489.3419432332041,176.33333333333334,1477.8838622416022,204.66666666666666,1472.154821745801,238.66666666666666C1466.42578125,272.6666666666667,1466.42578125,312.3333333333333,1466.42578125,332.1666666666667L1466.42578125,352" id="edge11" class="relation" marker-start="url(#compositionStart)"></path><path d="M1536.3874757751937,148L1542.116516270995,162.16666666666666C1547.8455567667959,176.33333333333334,1559.3036377583978,204.66666666666666,1565.032678254199,236.91666666666666C1570.76171875,269.1666666666667,1570.76171875,305.3333333333333,1570.76171875,323.4166666666667L1570.76171875,341.5" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1761.5546875,148L1761.5546875,162.16666666666666C1761.5546875,176.33333333333334,1761.5546875,204.66666666666666,1761.5546875,223C1761.5546875,241.33333333333334,1761.5546875,249.66666666666666,1761.5546875,253.83333333333334L1761.5546875,258" id="edge13" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file From cb0ef7d0d572d78a125222f60900ec8645de72e9 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 15:15:16 +0100 Subject: [PATCH 095/109] typo in comment + update author url --- dist/std.scm | 4 ++-- lib/byte-vectors.scm | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/std.scm b/dist/std.scm index d5a28b0e..b9316a6c 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -2799,12 +2799,12 @@ ;; ----------------------------------------------------------------------------- ;; Implementation of byte vector functions - SRFI-4 ;; -;; original code was ased on https://small.r7rs.org/wiki/NumericVectorsCowan/17/ +;; original code was based on https://small.r7rs.org/wiki/NumericVectorsCowan/17/ ;; it use JavaScript typed arrays ;; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays ;; ;; This file is part of the LIPS - Scheme based Powerful lisp in JavaScript -;; Copyright (C) 2019-2021 Jakub T. Jankiewicz <https://jcubic.pl> +;; Copyright (C) 2019-2021 Jakub T. Jankiewicz <https://jcubic.pl/me> ;; Released under MIT license ;; diff --git a/lib/byte-vectors.scm b/lib/byte-vectors.scm index 2a66e49e..5037e2ad 100644 --- a/lib/byte-vectors.scm +++ b/lib/byte-vectors.scm @@ -1,11 +1,11 @@ ;; Implementation of byte vector functions - SRFI-4 ;; -;; original code was ased on https://small.r7rs.org/wiki/NumericVectorsCowan/17/ +;; original code was based on https://small.r7rs.org/wiki/NumericVectorsCowan/17/ ;; it use JavaScript typed arrays ;; https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays ;; ;; This file is part of the LIPS - Scheme based Powerful lisp in JavaScript -;; Copyright (C) 2019-2021 Jakub T. Jankiewicz <https://jcubic.pl> +;; Copyright (C) 2019-2021 Jakub T. Jankiewicz <https://jcubic.pl/me> ;; Released under MIT license ;; From 88c01f2eb5462d262bb49a959322bb7534f421c8 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 7 Mar 2021 16:37:47 +0100 Subject: [PATCH 096/109] refactor names #119 --- .gitattributes | 1 + README.md | 2 +- assets/classDiagram | 36 ++++++-- assets/classDiagram.svg | 2 +- dist/lips.js | 174 +++++++++++++++++++++----------------- dist/lips.min.js | 4 +- dist/std.min.scm | 4 +- dist/std.scm | 4 +- examples/defstruct.scm | 2 +- examples/reader-macros.js | 2 +- lib/R5RS.scm | 2 +- lib/bootstrap.scm | 2 +- lib/js/terminal.js | 2 +- src/lips.js | 55 ++++++------ todo.lips | 6 +- 15 files changed, 171 insertions(+), 127 deletions(-) diff --git a/.gitattributes b/.gitattributes index 835d675d..0a600261 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ .* text eol=lf dist/* binary package-lock.json binary +assets/classDiagram.svg binary diff --git a/README.md b/README.md index 2b4e4d84..64648954 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&11a6d4523e97baf1803964e0eec34168ddf231c9)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&ea85de0c0d7205ca2e8f48ba8a556efb465dd079)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&37d92ca40f03da1d26598c0ee49db9a2)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/assets/classDiagram b/assets/classDiagram index 4432675c..736fe3d6 100644 --- a/assets/classDiagram +++ b/assets/classDiagram @@ -137,7 +137,7 @@ class Worker { exec(code, [dynamic]): Promise } class LCharacter { - string __name__ + string __name__ string __char__ toUpperCase(): LCharacter toLowerCase(): LCharacter @@ -145,10 +145,36 @@ class LCharacter { valueOf(): string } class Lexer { - string _input + string __input__ + token(meta) + peek(meta) + skip() + read_line() + read_rest() + read_string(num) + peek_char() + read_char() + skip_char() + match_rule() + next_token() + static rules } class Parser { Lexer __lexer__ + Environent __env__ + resolve() + peek() + skip() + read() + is_special(token) + is_builtin(token) + is_open(token) + is_close(token) + read_list() + read_value() + read_object() + is_ccomment(token) + evaluate(code) } class LSymbol { string __name__ @@ -204,9 +230,9 @@ class Pair { length() find(any) clone() - lastPair() - toArray() - toObject() + last_pair() + to_array() + to_object() reduce(Function) reverse(): Pair transform(Function) diff --git a/assets/classDiagram.svg b/assets/classDiagram.svg index 5877e4ef..173169a9 100644 --- a/assets/classDiagram.svg +++ b/assets/classDiagram.svg @@ -1 +1 @@ -<svg id="mermaid-1615126461173" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="596" style="max-width: 2799.1875px;" viewBox="-20 -20 2799.1875 596"><style>#mermaid-1615126461173{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1615126461173 .error-icon{fill:#552222;}#mermaid-1615126461173 .error-text{fill:#552222;stroke:#552222;}#mermaid-1615126461173 .edge-thickness-normal{stroke-width:2px;}#mermaid-1615126461173 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1615126461173 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1615126461173 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1615126461173 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1615126461173 .marker{fill:#333333;}#mermaid-1615126461173 .marker.cross{stroke:#333333;}#mermaid-1615126461173 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1615126461173 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1615126461173 g.classGroup text .title{font-weight:bolder;}#mermaid-1615126461173 .classTitle{font-weight:bolder;}#mermaid-1615126461173 .node rect,#mermaid-1615126461173 .node circle,#mermaid-1615126461173 .node ellipse,#mermaid-1615126461173 .node polygon,#mermaid-1615126461173 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1615126461173 .divider{stroke:#9370DB;stroke:1;}#mermaid-1615126461173 g.clickable{cursor:pointer;}#mermaid-1615126461173 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1615126461173 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1615126461173 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1615126461173 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1615126461173 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1615126461173 .dashed-line{stroke-dasharray:3;}#mermaid-1615126461173 #compositionStart,#mermaid-1615126461173 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #compositionEnd,#mermaid-1615126461173 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #dependencyStart,#mermaid-1615126461173 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #dependencyStart,#mermaid-1615126461173 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #extensionStart,#mermaid-1615126461173 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #extensionEnd,#mermaid-1615126461173 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #aggregationStart,#mermaid-1615126461173 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 #aggregationEnd,#mermaid-1615126461173 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615126461173 .edgeTerminals{font-size:11px;}#mermaid-1615126461173:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1615126461173 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(222.33203125,0 )"><rect x="0" y="0" width="98.828125" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="27.7734375">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="89.515625" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.9296875">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="89.515625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt __value__</tspan></text><line x1="0" y1="37" y2="37" x2="89.515625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(139.515625,293 )"><rect x="0" y="0" width="110.03125" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="33.109375">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="110.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __num__</tspan><tspan x="5" dy="10">LNumber __denom__</tspan></text><line x1="0" y1="47" y2="47" x2="110.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(299.546875,333 )"><rect x="0" y="0" width="98.828125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="34.7578125">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(448.375,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(588.796875,40 )"><rect x="0" y="0" width="82.203125" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.2421875">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="82.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Function _read</tspan></text><line x1="0" y1="37" y2="37" x2="82.203125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(589.40625,352 )"><rect x="0" y="0" width="80.984375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="80.984375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="80.984375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(594.28125,526 )"><rect x="0" y="0" width="71.234375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="71.234375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="71.234375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(803.44140625,70.5 )"><rect x="0" y="0" width="61.9375" height="67" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="61.9375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="61.9375"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(720.390625,346.5 )"><rect x="0" y="0" width="89.203125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="89.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] _buffer</tspan></text><line x1="0" y1="37" y2="37" x2="89.203125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(859.59375,341.5 )"><rect x="0" y="0" width="88.46875" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.5078125">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="88.46875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _filename</tspan><tspan x="5" dy="10">number _fd</tspan></text><line x1="0" y1="47" y2="47" x2="88.46875"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Parser-11" class="classGroup" transform="translate(990.296875,83.5 )"><rect x="0" y="0" width="87.375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="28.65625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="87.375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan></text><line x1="0" y1="37" y2="37" x2="87.375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Lexer-12" class="classGroup" transform="translate(998.0625,346.5 )"><rect x="0" y="0" width="71.84375" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.1484375">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="71.84375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _input</tspan></text><line x1="0" y1="37" y2="37" x2="71.84375"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Macro-13" class="classGroup" transform="translate(1127.671875,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-14" class="classGroup" transform="translate(1157.5,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-15" class="classGroup" transform="translate(1309.21875,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-16" class="classGroup" transform="translate(1265.5,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-17" class="classGroup" transform="translate(1442.1015625,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-18" class="classGroup" transform="translate(1446.75390625,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-19" class="classGroup" transform="translate(1536.09765625,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-20" class="classGroup" transform="translate(1665.46875,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-21" class="classGroup" transform="translate(1687.2109375,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-22" class="classGroup" transform="translate(1907.640625,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-23" class="classGroup" transform="translate(2073.890625,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-24" class="classGroup" transform="translate(2213.34375,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-25" class="classGroup" transform="translate(2352.796875,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-26" class="classGroup" transform="translate(2493.609375,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-27" class="classGroup" transform="translate(2653.859375,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">lastPair()</tspan><tspan x="5" dy="10">toArray()</tspan><tspan x="5" dy="10">toObject()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M222.33203125,132.08256896522053L192.736328125,148.90214080435044C163.140625,165.72171264348034,103.94921875,199.36085632174016,74.353515625,232.01376149420344C44.7578125,264.6666666666667,44.7578125,296.3333333333333,44.7578125,312.1666666666667L44.7578125,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M222.33203125,186.55425709515862L217.69856770833334,194.29521424596552C213.06510416666666,202.0361713967724,203.79817708333334,217.51808569838622,199.16471354166666,235.2590428491931C194.53125,253,194.53125,273,194.53125,283L194.53125,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,186.55425709515862L325.7936197916667,194.29521424596552C330.4270833333333,202.0361713967724,339.6940104166667,217.51808569838622,344.3274739583333,241.92570951585978C348.9609375,266.3333333333333,348.9609375,299.6666666666667,348.9609375,316.3333333333333L348.9609375,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,132.69489528565651L349.9485677083333,149.4124127380471C378.7369791666667,166.12993019043768,436.3138020833333,199.5649650952188,465.1022135416667,224.61581588094273C493.890625,249.66666666666666,493.890625,266.3333333333333,493.890625,274.6666666666667L493.890625,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,168L629.8984375,178.83333333333334C629.8984375,189.66666666666666,629.8984375,211.33333333333334,629.8984375,242C629.8984375,272.6666666666667,629.8984375,312.3333333333333,629.8984375,332.1666666666667L629.8984375,352" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,382L629.8984375,401.8333333333333C629.8984375,421.6666666666667,629.8984375,461.3333333333333,629.8984375,485.3333333333333C629.8984375,509.3333333333333,629.8984375,517.6666666666666,629.8984375,521.8333333333334L629.8984375,526" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M816.3830093265503,137.5L807.8178723554587,153.41666666666666C799.2527353843669,169.33333333333334,782.1224614421835,201.16666666666666,773.5573244710918,236C764.9921875,270.8333333333333,764.9921875,308.6666666666667,764.9921875,327.5833333333333L764.9921875,346.5" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M852.4373031734497,137.5L861.0024401445413,153.41666666666666C869.5675771156331,169.33333333333334,886.6978510578165,201.16666666666666,895.2629880289082,235.16666666666666C903.828125,269.1666666666667,903.828125,305.3333333333333,903.828125,323.4166666666667L903.828125,341.5" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M1033.984375,124.5L1033.984375,142.58333333333334C1033.984375,160.66666666666666,1033.984375,196.83333333333334,1033.984375,233.83333333333334C1033.984375,270.8333333333333,1033.984375,308.6666666666667,1033.984375,327.5833333333333L1033.984375,346.5" id="edge8" class="relation" marker-start="url(#compositionStart)"></path><path d="M1186.5,158L1186.5,170.5C1186.5,183,1186.5,208,1186.5,238.08333333333334C1186.5,268.1666666666667,1186.5,303.3333333333333,1186.5,320.9166666666667L1186.5,338.5" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M1327.8515625,119L1327.8515625,138C1327.8515625,157,1327.8515625,195,1327.8515625,224.83333333333334C1327.8515625,254.66666666666666,1327.8515625,276.3333333333333,1327.8515625,287.1666666666667L1327.8515625,298" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1500.8000242248063,148L1495.070983729005,162.16666666666666C1489.3419432332041,176.33333333333334,1477.8838622416022,204.66666666666666,1472.154821745801,238.66666666666666C1466.42578125,272.6666666666667,1466.42578125,312.3333333333333,1466.42578125,332.1666666666667L1466.42578125,352" id="edge11" class="relation" marker-start="url(#compositionStart)"></path><path d="M1536.3874757751937,148L1542.116516270995,162.16666666666666C1547.8455567667959,176.33333333333334,1559.3036377583978,204.66666666666666,1565.032678254199,236.91666666666666C1570.76171875,269.1666666666667,1570.76171875,305.3333333333333,1570.76171875,323.4166666666667L1570.76171875,341.5" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1761.5546875,148L1761.5546875,162.16666666666666C1761.5546875,176.33333333333334,1761.5546875,204.66666666666666,1761.5546875,223C1761.5546875,241.33333333333334,1761.5546875,249.66666666666666,1761.5546875,253.83333333333334L1761.5546875,258" id="edge13" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file +<svg id="mermaid-1615135637099" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="596" style="max-width: 2819.2890625px;" viewBox="-20 -20 2819.2890625 596"><style>#mermaid-1615135637099{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1615135637099 .error-icon{fill:#552222;}#mermaid-1615135637099 .error-text{fill:#552222;stroke:#552222;}#mermaid-1615135637099 .edge-thickness-normal{stroke-width:2px;}#mermaid-1615135637099 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1615135637099 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1615135637099 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1615135637099 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1615135637099 .marker{fill:#333333;}#mermaid-1615135637099 .marker.cross{stroke:#333333;}#mermaid-1615135637099 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1615135637099 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1615135637099 g.classGroup text .title{font-weight:bolder;}#mermaid-1615135637099 .classTitle{font-weight:bolder;}#mermaid-1615135637099 .node rect,#mermaid-1615135637099 .node circle,#mermaid-1615135637099 .node ellipse,#mermaid-1615135637099 .node polygon,#mermaid-1615135637099 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1615135637099 .divider{stroke:#9370DB;stroke:1;}#mermaid-1615135637099 g.clickable{cursor:pointer;}#mermaid-1615135637099 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1615135637099 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1615135637099 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1615135637099 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1615135637099 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1615135637099 .dashed-line{stroke-dasharray:3;}#mermaid-1615135637099 #compositionStart,#mermaid-1615135637099 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #compositionEnd,#mermaid-1615135637099 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #dependencyStart,#mermaid-1615135637099 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #dependencyStart,#mermaid-1615135637099 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #extensionStart,#mermaid-1615135637099 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #extensionEnd,#mermaid-1615135637099 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #aggregationStart,#mermaid-1615135637099 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #aggregationEnd,#mermaid-1615135637099 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 .edgeTerminals{font-size:11px;}#mermaid-1615135637099:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1615135637099 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(222.33203125,0 )"><rect x="0" y="0" width="98.828125" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="27.7734375">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="89.515625" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.9296875">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="89.515625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt __value__</tspan></text><line x1="0" y1="37" y2="37" x2="89.515625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(139.515625,293 )"><rect x="0" y="0" width="110.03125" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="33.109375">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="110.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __num__</tspan><tspan x="5" dy="10">LNumber __denom__</tspan></text><line x1="0" y1="47" y2="47" x2="110.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(299.546875,333 )"><rect x="0" y="0" width="98.828125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="34.7578125">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(448.375,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(588.796875,40 )"><rect x="0" y="0" width="82.203125" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.2421875">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="82.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Function _read</tspan></text><line x1="0" y1="37" y2="37" x2="82.203125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(589.40625,352 )"><rect x="0" y="0" width="80.984375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="80.984375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="80.984375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(594.28125,526 )"><rect x="0" y="0" width="71.234375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="71.234375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="71.234375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(803.44140625,70.5 )"><rect x="0" y="0" width="61.9375" height="67" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="61.9375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="61.9375"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(720.390625,346.5 )"><rect x="0" y="0" width="89.203125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="89.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] _buffer</tspan></text><line x1="0" y1="37" y2="37" x2="89.203125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(859.59375,341.5 )"><rect x="0" y="0" width="88.46875" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.5078125">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="88.46875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _filename</tspan><tspan x="5" dy="10">number _fd</tspan></text><line x1="0" y1="47" y2="47" x2="88.46875"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Parser-11" class="classGroup" transform="translate(990.8984375,10 )"><rect x="0" y="0" width="106.875" height="188" class=" "></rect><text y="15" x="0"><tspan class="title" x="38.40625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="106.875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan><tspan x="5" dy="10">Environent __env__</tspan></text><line x1="0" y1="47" y2="47" x2="106.875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">resolve()</tspan><tspan x="5" dy="10">peek()</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">is_special(token)</tspan><tspan x="5" dy="10">is_builtin(token)</tspan><tspan x="5" dy="10">is_open(token)</tspan><tspan x="5" dy="10">is_close(token)</tspan><tspan x="5" dy="10">read_list()</tspan><tspan x="5" dy="10">read_value()</tspan><tspan x="5" dy="10">read_object()</tspan><tspan x="5" dy="10">is_ccomment(token)</tspan><tspan x="5" dy="10">evaluate(code)</tspan></text></g><g id="classid-Lexer-12" class="classGroup" transform="translate(998.0625,283 )"><rect x="0" y="0" width="92.546875" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="32.5">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="92.546875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __input__</tspan><tspan x="5" dy="10">static rules</tspan></text><line x1="0" y1="47" y2="47" x2="92.546875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">token(meta)</tspan><tspan x="5" dy="10">peek(meta)</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read_rest()</tspan><tspan x="5" dy="10">read_string(num)</tspan><tspan x="5" dy="10">peek_char()</tspan><tspan x="5" dy="10">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">match_rule()</tspan><tspan x="5" dy="10">next_token()</tspan></text></g><g id="classid-Macro-13" class="classGroup" transform="translate(1147.7734375,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-14" class="classGroup" transform="translate(1177.6015625,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-15" class="classGroup" transform="translate(1329.3203125,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-16" class="classGroup" transform="translate(1285.6015625,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-17" class="classGroup" transform="translate(1462.203125,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-18" class="classGroup" transform="translate(1466.85546875,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-19" class="classGroup" transform="translate(1556.19921875,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-20" class="classGroup" transform="translate(1685.5703125,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-21" class="classGroup" transform="translate(1707.3125,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-22" class="classGroup" transform="translate(1927.7421875,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-23" class="classGroup" transform="translate(2093.9921875,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-24" class="classGroup" transform="translate(2233.4453125,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-25" class="classGroup" transform="translate(2372.8984375,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-26" class="classGroup" transform="translate(2513.7109375,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-27" class="classGroup" transform="translate(2673.9609375,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">last_pair()</tspan><tspan x="5" dy="10">to_array()</tspan><tspan x="5" dy="10">to_object()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M222.33203125,132.08256896522053L192.736328125,148.90214080435044C163.140625,165.72171264348034,103.94921875,199.36085632174016,74.353515625,232.01376149420344C44.7578125,264.6666666666667,44.7578125,296.3333333333333,44.7578125,312.1666666666667L44.7578125,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M222.33203125,186.55425709515862L217.69856770833334,194.29521424596552C213.06510416666666,202.0361713967724,203.79817708333334,217.51808569838622,199.16471354166666,235.2590428491931C194.53125,253,194.53125,273,194.53125,283L194.53125,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,186.55425709515862L325.7936197916667,194.29521424596552C330.4270833333333,202.0361713967724,339.6940104166667,217.51808569838622,344.3274739583333,241.92570951585978C348.9609375,266.3333333333333,348.9609375,299.6666666666667,348.9609375,316.3333333333333L348.9609375,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,132.69489528565651L349.9485677083333,149.4124127380471C378.7369791666667,166.12993019043768,436.3138020833333,199.5649650952188,465.1022135416667,224.61581588094273C493.890625,249.66666666666666,493.890625,266.3333333333333,493.890625,274.6666666666667L493.890625,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,168L629.8984375,178.83333333333334C629.8984375,189.66666666666666,629.8984375,211.33333333333334,629.8984375,242C629.8984375,272.6666666666667,629.8984375,312.3333333333333,629.8984375,332.1666666666667L629.8984375,352" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,382L629.8984375,401.8333333333333C629.8984375,421.6666666666667,629.8984375,461.3333333333333,629.8984375,485.3333333333333C629.8984375,509.3333333333333,629.8984375,517.6666666666666,629.8984375,521.8333333333334L629.8984375,526" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M816.3830093265503,137.5L807.8178723554587,153.41666666666666C799.2527353843669,169.33333333333334,782.1224614421835,201.16666666666666,773.5573244710918,236C764.9921875,270.8333333333333,764.9921875,308.6666666666667,764.9921875,327.5833333333333L764.9921875,346.5" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M852.4373031734497,137.5L861.0024401445413,153.41666666666666C869.5675771156331,169.33333333333334,886.6978510578165,201.16666666666666,895.2629880289082,235.16666666666666C903.828125,269.1666666666667,903.828125,305.3333333333333,903.828125,323.4166666666667L903.828125,341.5" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M1044.3359375,198L1044.3359375,203.83333333333334C1044.3359375,209.66666666666666,1044.3359375,221.33333333333334,1044.3359375,235.5C1044.3359375,249.66666666666666,1044.3359375,266.3333333333333,1044.3359375,274.6666666666667L1044.3359375,283" id="edge8" class="relation" marker-start="url(#compositionStart)"></path><path d="M1206.6015625,158L1206.6015625,170.5C1206.6015625,183,1206.6015625,208,1206.6015625,238.08333333333334C1206.6015625,268.1666666666667,1206.6015625,303.3333333333333,1206.6015625,320.9166666666667L1206.6015625,338.5" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M1347.953125,119L1347.953125,138C1347.953125,157,1347.953125,195,1347.953125,224.83333333333334C1347.953125,254.66666666666666,1347.953125,276.3333333333333,1347.953125,287.1666666666667L1347.953125,298" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1520.9015867248063,148L1515.172546229005,162.16666666666666C1509.4435057332041,176.33333333333334,1497.9854247416022,204.66666666666666,1492.256384245801,238.66666666666666C1486.52734375,272.6666666666667,1486.52734375,312.3333333333333,1486.52734375,332.1666666666667L1486.52734375,352" id="edge11" class="relation" marker-start="url(#compositionStart)"></path><path d="M1556.4890382751937,148L1562.218078770995,162.16666666666666C1567.9471192667959,176.33333333333334,1579.4052002583978,204.66666666666666,1585.134240754199,236.91666666666666C1590.86328125,269.1666666666667,1590.86328125,305.3333333333333,1590.86328125,323.4166666666667L1590.86328125,341.5" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1781.65625,148L1781.65625,162.16666666666666C1781.65625,176.33333333333334,1781.65625,204.66666666666666,1781.65625,223C1781.65625,241.33333333333334,1781.65625,249.66666666666666,1781.65625,253.83333333333334L1781.65625,258" id="edge13" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file diff --git a/dist/lips.js b/dist/lips.js index 20fb6ec3..77df7d53 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 13:06:05 +0000 + * build: Sun, 07 Mar 2021 16:47:22 +0000 */ (function () { 'use strict'; @@ -2682,8 +2682,7 @@ Lexer.bracket = Symbol["for"]('bracket'); Lexer.b_symbol = Symbol["for"]('b_symbol'); Lexer.b_comment = Symbol["for"]('b_comment'); - Lexer.i_comment = Symbol["for"]('i_comment'); - Lexer.character = Symbol["for"]('character'); // ---------------------------------------------------------------------- + Lexer.i_comment = Symbol["for"]('i_comment'); // ---------------------------------------------------------------------- Lexer.boundary = /^$|[\s()[\]]/; // ---------------------------------------------------------------------- @@ -2781,10 +2780,14 @@ arg = arg.toString(); } - this._formatter = formatter; - this._meta = meta; - this.__lexer__ = new Lexer(arg); - this.__env__ = env; + read_only(this, '_formatter', formatter, { + hidden: true + }); + read_only(this, '_meta', meta, { + hidden: true + }); + read_only(this, '__lexer__', new Lexer(arg)); + read_only(this, '__env__', env); } createClass(Parser, [{ @@ -2880,13 +2883,13 @@ this.__lexer__.skip(); } }, { - key: "special", - value: function special(token) { + key: "is_special", + value: function is_special(token) { return specials.names().includes(token); } }, { - key: "builtin", - value: function builtin(token) { + key: "is_builtin", + value: function is_builtin(token) { return specials.builtin.includes(token); } }, { @@ -3064,9 +3067,9 @@ return token.match(/^;/) || token.match(/^#\|/) && token.match(/\|#$/); } }, { - key: "_eval", - value: function _eval(code) { - return evaluate(code, { + key: "evaluate", + value: function evaluate(code) { + return _evaluate(code, { env: this.__env__, error: function error(e) { throw e; @@ -3096,7 +3099,7 @@ return _context5.abrupt("return", token); case 5: - if (!this.special(token)) { + if (!this.is_special(token)) { _context5.next = 35; break; } @@ -3109,7 +3112,7 @@ // MACRO: if macros are used they are evaluated in place and // result is returned by parser but they are quoted special = specials.get(token); - bultin = this.builtin(token); + bultin = this.is_builtin(token); this.skip(); _context5.next = 11; return this.read_object(); @@ -3142,7 +3145,7 @@ break; } - return _context5.abrupt("return", extension.apply(this.__env__, object.toArray(false))); + return _context5.abrupt("return", extension.apply(this.__env__, object.to_array(false))); case 21: throw new Error('Parser: Invalid parser extension ' + "invocation ".concat(special.symbol)); @@ -3169,7 +3172,7 @@ } _context5.next = 28; - return this._eval(expr); + return this.evaluate(expr); case 28: result = _context5.sent; @@ -4175,7 +4178,7 @@ return undefined$1; }; - Nil.prototype.toObject = function () { + Nil.prototype.to_object = function () { return {}; }; @@ -4183,7 +4186,7 @@ return new Pair(x, nil); }; - Nil.prototype.toArray = function () { + Nil.prototype.to_array = function () { return []; }; @@ -4201,7 +4204,7 @@ } // ---------------------------------------------------------------------- - function toArray$1(name, deep) { + function to_array(name, deep) { return function recur(list) { typecheck(name, list, ['pair', 'nil']); @@ -4239,7 +4242,7 @@ Pair.prototype.flatten = function () { - return Pair.fromArray(flatten(this.toArray())); + return Pair.fromArray(flatten(this.to_array())); }; // ---------------------------------------------------------------------- @@ -4315,7 +4318,7 @@ }; // ---------------------------------------------------------------------- - Pair.prototype.lastPair = function () { + Pair.prototype.last_pair = function () { var node = this; while (true) { @@ -4328,13 +4331,13 @@ }; // ---------------------------------------------------------------------- - Pair.prototype.toArray = function () { + Pair.prototype.to_array = function () { var deep = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : true; var result = []; if (this.car instanceof Pair) { if (deep) { - result.push(this.car.toArray()); + result.push(this.car.to_array()); } else { result.push(this.car); } @@ -4343,7 +4346,7 @@ } if (this.cdr instanceof Pair) { - result = result.concat(this.cdr.toArray()); + result = result.concat(this.cdr.to_array()); } return result; @@ -4391,13 +4394,13 @@ return result; }; // ---------------------------------------------------------------------- - // by default toObject was created to create JavaScript objects, + // by default to_object was created to create JavaScript objects, // so it use valueOf to get native values // literal parameter was a hack to allow create LComplex from LIPS code // ---------------------------------------------------------------------- - Pair.prototype.toObject = function () { + Pair.prototype.to_object = function () { var literal = arguments.length > 0 && arguments[0] !== undefined$1 ? arguments[0] : false; var node = this; var result = {}; @@ -4418,7 +4421,7 @@ var cdr = pair.cdr; if (cdr instanceof Pair) { - cdr = cdr.toObject(literal); + cdr = cdr.to_object(literal); } if (is_native(cdr)) { @@ -5623,7 +5626,7 @@ if (pattern.car.cdr instanceof Pair && LSymbol.is(pattern.car.cdr.car, ellipsis_symbol)) { var _name2 = pattern.car.car.valueOf(); - var last = pattern.lastPair(); + var last = pattern.last_pair(); if (LSymbol.is(last.car, ellipsis_symbol)) { bindings['...'].symbols[_name2] = null; @@ -6754,7 +6757,7 @@ function exec() { var output = new Pair(new LSymbol('begin'), code.cdr); - return evaluate(output, { + return _evaluate(output, { env: env, dynamic_scope: dynamic_scope, error: error @@ -6799,7 +6802,7 @@ var_body_env = env; } - var value = evaluate(pair.cdr.car, { + var value = _evaluate(pair.cdr.car, { env: var_body_env, dynamic_scope: dynamic_scope, error: error @@ -6843,7 +6846,7 @@ var results = []; while (node instanceof Pair) { - results.push(evaluate(node.car, { + results.push(_evaluate(node.car, { env: env, dynamic_scope: dynamic_scope, error: error @@ -10179,7 +10182,7 @@ dynamic_scope = this; } - var ret = evaluate(code.car, { + var ret = _evaluate(code.car, { env: env, error: error, dynamic_scope: dynamic_scope @@ -10239,11 +10242,13 @@ var env = this; var ref; - var value = evaluate(code.cdr.car, { + + var value = _evaluate(code.cdr.car, { env: this, dynamic_scope: dynamic_scope, error: error }); + value = resolve_promises(value); function set(object, key, value) { @@ -10272,16 +10277,19 @@ if (code.car instanceof Pair && LSymbol.is(code.car.car, '.')) { var second = code.car.cdr.car; var thrid = code.car.cdr.cdr.car; - var object = evaluate(second, { + + var object = _evaluate(second, { env: this, dynamic_scope: dynamic_scope, error: error }); - var key = evaluate(thrid, { + + var key = _evaluate(thrid, { env: this, dynamic_scope: dynamic_scope, error: error }); + return set(object, key, value); } @@ -10470,7 +10478,7 @@ _context13.t0 = scope; _context13.t1 = item.car; _context13.next = 16; - return evaluate(item.cdr.car, eval_args); + return _evaluate(item.cdr.car, eval_args); case 16: _context13.t2 = _context13.sent; @@ -10520,7 +10528,7 @@ } _context12.next = 10; - return evaluate(_item.cdr.cdr.car, eval_args); + return _evaluate(_item.cdr.cdr.car, eval_args); case 10: value = _context12.sent; @@ -10547,7 +10555,7 @@ case 23: _context13.next = 25; - return evaluate(test.car, eval_args); + return _evaluate(test.car, eval_args); case 25: _context13.t3 = _context13.sent; @@ -10570,7 +10578,7 @@ } _context13.next = 33; - return evaluate(test.cdr.car, eval_args); + return _evaluate(test.cdr.car, eval_args); case 33: return _context13.abrupt("return", _context13.sent); @@ -10600,13 +10608,13 @@ var resolve = function resolve(cond) { if (cond === false) { - return evaluate(code.cdr.cdr.car, { + return _evaluate(code.cdr.cdr.car, { env: env, dynamic_scope: dynamic_scope, error: error }); } else { - return evaluate(code.cdr.car, { + return _evaluate(code.cdr.car, { env: env, dynamic_scope: dynamic_scope, error: error @@ -10618,11 +10626,12 @@ throw new Error('too few expressions for `if`'); } - var cond = evaluate(code.car, { + var cond = _evaluate(code.car, { env: env, dynamic_scope: dynamic_scope, error: error }); + return unpromise(cond, resolve); }), "(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"), // ------------------------------------------------------------------ @@ -10631,14 +10640,16 @@ var dynamic_scope = options.dynamic_scope, error = options.error; typecheck('let-env', code, 'pair'); - var ret = evaluate(code.car, { + + var ret = _evaluate(code.car, { env: this, dynamic_scope: dynamic_scope, error: error }); + return unpromise(ret, function (value) { typecheck('let-env', value, 'environment'); - return evaluate(Pair(LSymbol('begin'), code.cdr), { + return _evaluate(Pair(LSymbol('begin'), code.cdr), { env: value, dynamic_scope: dynamic_scope, error: error @@ -10671,7 +10682,9 @@ return function loop() { if (arr.length) { var code = arr.shift(); - var ret = evaluate(code, args); + + var ret = _evaluate(code, args); + return unpromise(ret, function (value) { result = value; return loop(); @@ -10694,7 +10707,7 @@ args.dynamic_scope = this; } - evaluate(new Pair(new LSymbol('begin'), code), args); + _evaluate(new Pair(new LSymbol('begin'), code), args); }, "(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 (code, eval_args) { @@ -10717,7 +10730,7 @@ var new_expr; if (value instanceof Pair) { - value = evaluate(value, eval_args); + value = _evaluate(value, eval_args); new_expr = true; } else if (value instanceof LSymbol) { value = env.get(value); @@ -10810,7 +10823,7 @@ var _this17 = this; env = env || this; - return evaluate(code, { + return _evaluate(code, { env: env, //dynamic_scope: this, error: function error(e) { @@ -10923,7 +10936,7 @@ var rest = __doc__ ? code.cdr.cdr : code.cdr; var output = new Pair(new LSymbol('begin'), rest); - return evaluate(output, { + return _evaluate(output, { env: env, dynamic_scope: dynamic_scope, error: error @@ -11007,7 +11020,7 @@ // this eval will return lips code var rest = __doc__ ? macro.cdr.cdr : macro.cdr; var result = rest.reduce(function (result, node) { - return evaluate(node, eval_args); + return _evaluate(node, eval_args); }); return unpromise(result, function (result) { if (_typeof_1(result) === 'object') { @@ -11138,13 +11151,14 @@ }; } - var result = evaluate(expr, _objectSpread(_objectSpread({}, eval_args), {}, { + var result = _evaluate(expr, _objectSpread(_objectSpread({}, eval_args), {}, { env: new_env })); // Hack: update the result if there are generated // gensyms that should be literal symbols // TODO: maybe not the part move when literal elisps may // be generated, maybe they will need to be mark somehow + return clear_gensyms(result, names); } @@ -11248,7 +11262,7 @@ if (unquote_cnt + 1 < max_unq) { result = recur(x.cdr, unquote_cnt + 1, max_unq); } else { - result = evaluate(x.cdr.car, { + result = _evaluate(x.cdr.car, { env: self, dynamic_scope: dynamic_scope, error: error @@ -11259,7 +11273,7 @@ throw new Error("Expecting list ".concat(type(x), " found")); } - return acc.concat(result.toArray()); + return acc.concat(result.to_array()); } acc.push(recur(x, unquote_cnt, max_unq)); @@ -11284,7 +11298,7 @@ if (unquote_cnt < max_unq) { output = recur(value.cdr.car, unquote_cnt, max_unq); } else { - output = evaluate(value.cdr.car, { + output = _evaluate(value.cdr.car, { env: self, dynamic_scope: dynamic_scope, error: error @@ -11312,11 +11326,12 @@ var lists = []; return function next(node) { - var value = evaluate(node.car, { + var value = _evaluate(node.car, { env: self, dynamic_scope: dynamic_scope, error: error }); + lists.push(value); if (node.cdr instanceof Pair) { @@ -11407,7 +11422,7 @@ return Pair.fromArray(result); } - return unpromise(evaluate(node.car, { + return unpromise(_evaluate(node.car, { env: self, dynamic_scope: dynamic_scope, error: error @@ -11454,7 +11469,7 @@ return Pair.fromArray(_result3); } - return unpromise(evaluate(node.car, { + return unpromise(_evaluate(node.car, { env: self, dynamic_scope: dynamic_scope, error: error @@ -11468,7 +11483,7 @@ return pair.cdr; } } else { - return evaluate(pair.cdr.car, { + return _evaluate(pair.cdr.car, { env: self, dynamic_scope: dynamic_scope, error: error @@ -11826,9 +11841,9 @@ return Pair.fromArray(array); }, "(array->list array)\n\n Function convert JavaScript array to LIPS list."), // ------------------------------------------------------------------ - 'tree->array': doc('tree->array', toArray$1('tree->array', true), "(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."), + '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', toArray$1('list->array'), "(list->array list)\n\n Function convert LIPS list 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 apply(fn) { for (var _len28 = arguments.length, args = new Array(_len28 > 1 ? _len28 - 1 : 0), _key28 = 1; _key28 < _len28; _key28++) { @@ -11910,7 +11925,7 @@ _next = function next(result, cont) { // prevent infinite loop when finally throw exception _next = reject; - unpromise(evaluate(new Pair(new LSymbol('begin'), finally_clause.cdr), args), function () { + unpromise(_evaluate(new Pair(new LSymbol('begin'), finally_clause.cdr), args), function () { cont(result); }); }; @@ -11932,7 +11947,7 @@ args.dynamic_scope = _this18; } - unpromise(evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { + unpromise(_evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { _next(result, resolve); }); } else { @@ -11945,7 +11960,7 @@ args.dynamic_scope = _this18; } - var result = evaluate(code.car, args); + var result = _evaluate(code.car, args); if (is_promise(result)) { result.then(function (result) { @@ -12419,11 +12434,13 @@ } } else { var arg = args.shift(); - var value = evaluate(arg, { + + var value = _evaluate(arg, { env: self, dynamic_scope: dynamic_scope, error: error }); + return unpromise(value, next); } }(); @@ -12466,11 +12483,12 @@ return false; } } else { - var value = evaluate(arg, { + var value = _evaluate(arg, { env: self, dynamic_scope: dynamic_scope, error: error }); + return unpromise(value, next); } }(); @@ -12709,7 +12727,7 @@ var match = false; if (expected instanceof Pair) { - expected = expected.toArray(); + expected = expected.to_array(); } if (expected instanceof Array) { @@ -12964,7 +12982,7 @@ return function loop() { if (node instanceof Pair) { - var arg = evaluate(node.car, { + var arg = _evaluate(node.car, { env: env, dynamic_scope: dynamic_scope, error: error @@ -13026,7 +13044,7 @@ if (value && value[__data__] || !value || self_evaluated(value)) { return value; } else { - return unpromise(evaluate(value, eval_args), finalize); + return unpromise(_evaluate(value, eval_args), finalize); } }); } // ------------------------------------------------------------------------- @@ -13120,7 +13138,7 @@ } // ------------------------------------------------------------------------- - function evaluate(code) { + function _evaluate(code) { var _ref44 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, env = _ref44.env, dynamic_scope = _ref44.dynamic_scope, @@ -13159,11 +13177,11 @@ var rest = code.cdr; if (first instanceof Pair) { - value = resolve_promises(evaluate(first, eval_args)); + value = resolve_promises(_evaluate(first, eval_args)); if (is_promise(value)) { return value.then(function (value) { - return evaluate(new Pair(value, code.cdr), eval_args); + return _evaluate(new Pair(value, code.cdr), eval_args); }); // else is later in code } else if (!is_function(value)) { throw new Error(type(value) + ' ' + env.get('repr')(value) + ' is not a function while evaluating ' + code.toString()); @@ -13260,7 +13278,7 @@ } code = _value3; - value = evaluate(code, { + value = _evaluate(code, { env: env, dynamic_scope: dynamic_scope, error: function error(e, code) { @@ -13699,10 +13717,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 07 Mar 2021 13:06:05 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Sun, 07 Mar 2021 16:47:22 +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('Sun, 07 Mar 2021 13:06:05 +0000').valueOf(); + var date = LString('Sun, 07 Mar 2021 16:47:22 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13742,12 +13760,12 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 07 Mar 2021 13:06:05 +0000', + date: 'Sun, 07 Mar 2021 16:47:22 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), tokenize: tokenize, - evaluate: evaluate, + evaluate: _evaluate, bootstrap: bootstrap, Environment: Environment, env: user_env, diff --git a/dist/lips.min.js b/dist/lips.min.js index 2e3cc0bf..5ada83c3 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 13:06:05 +0000 + * build: Sun, 07 Mar 2021 16:47:22 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.character=Symbol["for"]("character");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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()}this._formatter=u;this._meta=i;this.__lexer__=new Lexer(e);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:"special",value:function e(r){return specials.names().includes(r)}},{key:"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:"_eval",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.special(t)){r.next=35;break}n=specials.get(t);i=this.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.toArray(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._eval(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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.toObject=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.toArray=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function toArray$1(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.toArray()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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.lastPair=function(){var e=this;while(true){if(e.cdr===nil){return e}e=e.cdr}};Pair.prototype.toArray=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.toArray())}else{r.push(this.car)}}else{r.push(this.car.valueOf())}if(this.cdr instanceof Pair){r=r.concat(this.cdr.toArray())}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.toObject=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.toObject(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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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.lastPair();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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.toArray())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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",toArray$1("tree->array",true),"(tree->array list)\n\n Function convert LIPS list structure into JavaScript array."),"list->array":doc("list->array",toArray$1("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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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.toArray()}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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 13:06:05 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 13:06:05 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 16:47:22 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 16:47:22 +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/dist/std.min.scm b/dist/std.min.scm index 981408fd..bbf083aa 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -15,7 +15,7 @@ (define typed-array? (let ((TypedArray (Object.getPrototypeOf Uint8Array))) (lambda (o) "(typed-array? o)\u000A\u000AFunction test if argumnet is JavaScript typed array (Scheme byte vector)." (instanceof TypedArray o)))) (define (symbol->string s) "(symbol->string symbol)\u000A\u000AFunction convert LIPS symbol to string." (if (symbol? s) (let ((name s.__name__)) (if (string? name) name (--> name (toString)))))) (define (string->symbol string) "(string->symbol string)\u000A\u000AFunction convert string to LIPS symbol." (and (string? string) (%as.data (new (. lips "LSymbol") string)))) -(define (alist->object alist) "(alist->object alist)\u000A\u000AFunction convert alist pairs to JavaScript object." (if (pair? alist) (alist.toObject) (alist->object (new lips.Pair undefined ())))) +(define (alist->object alist) "(alist->object alist)\u000A\u000AFunction convert alist pairs to JavaScript object." (if (pair? alist) (alist.to_object) (alist->object (new lips.Pair undefined ())))) (define (parent.frames) "(parent.frames)\u000A\u000AFuncion return list of environments from parent frames (lambda function calls)" (let iter ((result (quote ())) (frame (parent.frame 1))) (if (eq? frame (interaction-environment)) (cons frame result) (if (null? frame) result (let ((parent.frame (--> frame (get (quote parent.frame) (object :throwError #f))))) (if (function? parent.frame) (iter (cons frame result) (parent.frame 0)) result)))))) (define-macro (wait time . expr) "(wait time . expr)\u000A\u000AFunction return promise that will resolve with evaluating the expression after delay." (quasiquote (promise (timer (unquote time) (resolve (begin (unquote-splicing expr))))))) (define (pair-map fn seq-list) "(pair-map fn list)\u000A\u000AFunction call fn argument for pairs in a list and return combined list with\u000Avalues returned from function fn. It work like the map but take two items from list" (let iter ((seq-list seq-list) (result (quote ()))) (if (null? seq-list) result (if (and (pair? seq-list) (pair? (cdr seq-list))) (let* ((first (car seq-list)) (second (cadr seq-list)) (value (fn first second))) (if (null? value) (iter (cddr seq-list) result) (iter (cddr seq-list) (cons value result)))))))) @@ -147,7 +147,7 @@ (define numbers? (curry typecheck-args "number")) (define (max . args) "(max n1 n2 ...)\u000A\u000AReturn maximum of it's arguments." (numbers? "max" args) (apply (.. Math.max) args)) (define (min . args) "(min n1 n2 ...)\u000A\u000AReturn minimum of it's arguments." (numbers? "min" args) (apply (.. Math.min) args)) -(define (make-rectangular re im) "(make-rectangular im re)\u000A\u000ACreate complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (toObject #t))))) +(define (make-rectangular re im) "(make-rectangular im re)\u000A\u000ACreate complex number from imaginary and real part." (let ((value (quasiquote ((re unquote re) (im unquote im))))) (lips.LComplex (--> value (to_object #t))))) (define (exact? n) "(exact? n)" (typecheck "exact?" n "number") (let ((type n.__type__)) (or (string=? type "bigint") (string=? type "rational") (and (string=? type "complex") (exact? n.__im__) (exact? n.__re__))))) (define (inexact? n) "(inexact? n)" (typecheck "inexact?" n "number") (not (exact? n))) (define (exact->inexact n) "(exact->inexact n)\u000A\u000AConvert exact number to inexact." (typecheck "exact->inexact" n "number") (if (%number-type "complex" n) (lips.LComplex (object :im (exact->inexact (. n (quote __im__))) :re (exact->inexact (. n (quote __re__))))) (if (or (rational? n) (integer? n)) (lips.LFloat (--> n (valueOf)) #t) n))) diff --git a/dist/std.scm b/dist/std.scm index b9316a6c..42ace5df 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -225,7 +225,7 @@ Function convert alist pairs to JavaScript object." (if (pair? alist) - (alist.toObject) + (alist.to_object) (alist->object (new lips.Pair undefined nil)))) ;; ----------------------------------------------------------------------------- @@ -1770,7 +1770,7 @@ Create complex number from imaginary and real part." (let ((value `((re . ,re) (im . ,im)))) - (lips.LComplex (--> value (toObject true))))) + (lips.LComplex (--> value (to_object true))))) ;; ----------------------------------------------------------------------------- (define (exact? n) diff --git a/examples/defstruct.scm b/examples/defstruct.scm index 48a897a9..2f2df7cf 100644 --- a/examples/defstruct.scm +++ b/examples/defstruct.scm @@ -34,7 +34,7 @@ (define (defstruct:alist->object arg) "Function create JavaScript object from AList" (typecheck "defstruct:every" arg "pair") - (--> arg (toObject))) + (--> arg (to_object))) (define (defstruct:every fn list) "return true if every element return true for a function applied to every element" diff --git a/examples/reader-macros.js b/examples/reader-macros.js index e1239faf..aaa32d9d 100644 --- a/examples/reader-macros.js +++ b/examples/reader-macros.js @@ -45,7 +45,7 @@ return obj; }); return new Pair(car, cdr); - }).toObject(); + }).to_object(); })); env.set('object->string', function(obj) { return JSON.stringify(obj); diff --git a/lib/R5RS.scm b/lib/R5RS.scm index b5caa0ed..9028250e 100755 --- a/lib/R5RS.scm +++ b/lib/R5RS.scm @@ -389,7 +389,7 @@ Create complex number from imaginary and real part." (let ((value `((re . ,re) (im . ,im)))) - (lips.LComplex (--> value (toObject true))))) + (lips.LComplex (--> value (to_object true))))) ;; ----------------------------------------------------------------------------- (define (exact? n) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 7d212a21..e266b06a 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -225,7 +225,7 @@ Function convert alist pairs to JavaScript object." (if (pair? alist) - (alist.toObject) + (alist.to_object) (alist->object (new lips.Pair undefined nil)))) ;; ----------------------------------------------------------------------------- diff --git a/lib/js/terminal.js b/lib/js/terminal.js index 5fa6ccde..31467750 100755 --- a/lib/js/terminal.js +++ b/lib/js/terminal.js @@ -203,7 +203,7 @@ function terminal({selector, lips, dynamic = false, name = 'terminal'}, undefine // Array.from is need to for jQuery terminal version <2.5.0 // when terminal is outside iframe and lips is inside // jQuery Terminal was using instanceof that don't work between iframes - var env = Array.from(interpreter.get('env')().toArray()); + var env = Array.from(interpreter.get('env')().to_array()); if (!tokens.length) { return env; } diff --git a/src/lips.js b/src/lips.js index 9a84d374..afd53287 100644 --- a/src/lips.js +++ b/src/lips.js @@ -1169,7 +1169,6 @@ Lexer.b_symbol = Symbol.for('b_symbol'); Lexer.b_comment = Symbol.for('b_comment'); Lexer.i_comment = Symbol.for('i_comment'); - Lexer.character = Symbol.for('character'); // ---------------------------------------------------------------------- Lexer.boundary = /^$|[\s()[\]]/; // ---------------------------------------------------------------------- @@ -1296,10 +1295,10 @@ if (arg instanceof LString) { arg = arg.toString(); } - this._formatter = formatter; - this._meta = meta; - this.__lexer__ = new Lexer(arg); - this.__env__ = env; + read_only(this, '_formatter', formatter, { hidden: true }); + read_only(this, '_meta', meta, { hidden: true }); + read_only(this, '__lexer__', new Lexer(arg)); + read_only(this, '__env__', env); } resolve(name) { return this.__env__ && this.__env__.get(name, { throwError: false }); @@ -1334,10 +1333,10 @@ skip() { this.__lexer__.skip(); } - special(token) { + is_special(token) { return specials.names().includes(token); } - builtin(token) { + is_builtin(token) { return specials.builtin.includes(token); } async read() { @@ -1387,7 +1386,7 @@ is_comment(token) { return token.match(/^;/) || (token.match(/^#\|/) && token.match(/\|#$/)); } - _eval(code) { + evaluate(code) { return evaluate(code, { env: this.__env__, error: (e) => { throw e; } }); @@ -1397,7 +1396,7 @@ if (token === eof) { return token; } - if (this.special(token)) { + if (this.is_special(token)) { // bultin parser extensions are mapping short symbol to longer symbol // that can be function or macro, parser don't care // if it's not bultin then the extension can be macro or function @@ -1406,7 +1405,7 @@ // MACRO: if macros are used they are evaluated in place and // result is returned by parser but they are quoted const special = specials.get(token); - const bultin = this.builtin(token); + const bultin = this.is_builtin(token); this.skip(); let expr; const object = await this.read_object(); @@ -1416,7 +1415,7 @@ if (is_literal(token)) { return extension.call(this.__env__, object); } else if (object instanceof Pair) { - return extension.apply(this.__env__, object.toArray(false)); + return extension.apply(this.__env__, object.to_array(false)); } throw new Error('Parser: Invalid parser extension ' + `invocation ${special.symbol}`); @@ -1442,7 +1441,7 @@ } // evaluate parser extension at parse time if (extension instanceof Macro) { - var result = await this._eval(expr); + var result = await this.evaluate(expr); // we need literal quote to make macro that return pair works // because after parser return the value it will be evaluated again // by the interpreter, so we create quoted expression @@ -2112,13 +2111,13 @@ 'This is probably not what you want.'); return undefined; }; - Nil.prototype.toObject = function() { + Nil.prototype.to_object = function() { return {}; }; Nil.prototype.append = function(x) { return new Pair(x, nil); }; - Nil.prototype.toArray = function() { + Nil.prototype.to_array = function() { return []; }; var nil = new Nil(); @@ -2134,7 +2133,7 @@ this.cdr = cdr; } // ---------------------------------------------------------------------- - function toArray(name, deep) { + function to_array(name, deep) { return function recur(list) { typecheck(name, list, ['pair', 'nil']); if (list === nil) { @@ -2164,7 +2163,7 @@ } // ---------------------------------------------------------------------- Pair.prototype.flatten = function() { - return Pair.fromArray(flatten(this.toArray())); + return Pair.fromArray(flatten(this.to_array())); }; // ---------------------------------------------------------------------- Pair.prototype.length = function() { @@ -2227,7 +2226,7 @@ }; // ---------------------------------------------------------------------- - Pair.prototype.lastPair = function() { + Pair.prototype.last_pair = function() { let node = this; while (true) { if (node.cdr === nil) { @@ -2238,11 +2237,11 @@ }; // ---------------------------------------------------------------------- - Pair.prototype.toArray = function(deep = true) { + Pair.prototype.to_array = function(deep = true) { var result = []; if (this.car instanceof Pair) { if (deep) { - result.push(this.car.toArray()); + result.push(this.car.to_array()); } else { result.push(this.car); } @@ -2250,7 +2249,7 @@ result.push(this.car.valueOf()); } if (this.cdr instanceof Pair) { - result = result.concat(this.cdr.toArray()); + result = result.concat(this.cdr.to_array()); } return result; }; @@ -2287,11 +2286,11 @@ }; // ---------------------------------------------------------------------- - // by default toObject was created to create JavaScript objects, + // by default to_object was created to create JavaScript objects, // so it use valueOf to get native values // literal parameter was a hack to allow create LComplex from LIPS code // ---------------------------------------------------------------------- - Pair.prototype.toObject = function(literal = false) { + Pair.prototype.to_object = function(literal = false) { var node = this; var result = {}; while (true) { @@ -2306,7 +2305,7 @@ } var cdr = pair.cdr; if (cdr instanceof Pair) { - cdr = cdr.toObject(literal); + cdr = cdr.to_object(literal); } if (is_native(cdr)) { if (!literal) { @@ -3183,7 +3182,7 @@ if (pattern.car.cdr instanceof Pair && LSymbol.is(pattern.car.cdr.car, ellipsis_symbol)) { let name = pattern.car.car.valueOf(); - const last = pattern.lastPair(); + const last = pattern.last_pair(); if (LSymbol.is(last.car, ellipsis_symbol)) { bindings['...'].symbols[name] = null; return true; @@ -7501,7 +7500,7 @@ if (!(result instanceof Pair)) { throw new Error(`Expecting list ${type(x)} found`); } - return acc.concat(result.toArray()); + return acc.concat(result.to_array()); } acc.push(recur(x, unquote_cnt, max_unq)); return acc; @@ -8134,14 +8133,14 @@ // ------------------------------------------------------------------ 'tree->array': doc( 'tree->array', - toArray('tree->array', true), + to_array('tree->array', true), `(tree->array list) Function convert LIPS list structure into JavaScript array.`), // ------------------------------------------------------------------ 'list->array': doc( 'list->array', - toArray('list->array'), + to_array('list->array'), `(list->array list) Function convert LIPS list into JavaScript array.`), @@ -9004,7 +9003,7 @@ const arg_type = type(arg).toLowerCase(); var match = false; if (expected instanceof Pair) { - expected = expected.toArray(); + expected = expected.to_array(); } if (expected instanceof Array) { expected = expected.map(x => x.valueOf()); diff --git a/todo.lips b/todo.lips index 359321a7..7cf580e3 100644 --- a/todo.lips +++ b/todo.lips @@ -207,7 +207,7 @@ (data `((activeTodoCount . ,active-count) (activeTodoWord . ,(pluralize active-count "item")) (completedTodos . ,(- todo-count active-count)))) - (template (footer-template (--> data (toObject))))) + (template (footer-template (--> data (to_object))))) (--> ($ ".footer") (toggle (> todo-count 0)) (html template)))) @@ -216,7 +216,7 @@ (define (render) "render the app" (let* ((todos (get-todos)) - (data (--> (map (lambda (e) (--> e (toObject))) todos) (toArray)))) + (data (--> (map (lambda (e) (--> e (to_object))) todos) (to_array)))) (--> ($ ".todo-list") (html (todo-template data))) (--> ($ ".main") (toggle (> (length data) 0))) @@ -248,7 +248,7 @@ (let* ((routes `(("/:filter" . ,(lambda (filter) (set! selected-filter filter) (render))))) - (router (new Router (--> routes (toObject))))) + (router (new Router (--> routes (to_object))))) (--> router (init "/all")))) (init) From a7497cbe0352b8b6a7311075108de4ad8c5ddac1 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 9 Mar 2021 16:48:45 +0100 Subject: [PATCH 097/109] update UML diagram with I/O classes #132 --- assets/classDiagram | 98 +++++++++++++++++++++++++++++++++++++---- assets/classDiagram.svg | 2 +- 2 files changed, 91 insertions(+), 9 deletions(-) diff --git a/assets/classDiagram b/assets/classDiagram index 736fe3d6..c27bfc22 100644 --- a/assets/classDiagram +++ b/assets/classDiagram @@ -8,6 +8,10 @@ InputPort <|-- InputStringPort InputStringPort <|-- InputFilePort OutputPort <|-- OutputStringPort OutputPort <|-- OutputFilePort +OutputPort <|-- OutputByteVectorPort +InputPort <|-- InputByteVectorPort +InputByteVectorPort <|-- InputBinaryFilePort +OutputFilePort <|-- OutputBinaryFilePort Parser *-- Lexer Macro <|-- Syntax @@ -25,12 +29,12 @@ class LRational { pow() abs() cmp() - valueOf() - toString() mul() div() sub() add() + valueOf() + toString() } class LBigInteger { @@ -38,13 +42,14 @@ class LBigInteger { sqrt() gcd() sqrt() - } + class LFloat { Number __value__ toRational() toString() } + class LNumber { Number __value__ isFloat() @@ -63,8 +68,8 @@ class LNumber { isOdd() isEven() cmp() - } + class LComplex { LNumber __im__ LNumber __re__ @@ -82,7 +87,7 @@ class LComplex { } class InputPort { - Function _read + Parser __parser__ read_char() skip_char() read_line() @@ -92,19 +97,84 @@ class InputPort { close() toString() } + class OutputPort { + symbol __type__ + write() is_open() close() toString() } class OutputStringPort { - string[] _buffer + string[] __buffer__ + symbol __type__ + write() + valueOf() + toString() } + +class InputBinaryFilePort { + string __filename__ + toString() +} + +class InputStringPort { + symbol __type__ + char_ready() + toString() +} + +class InputFilePort { + string __filename__ + toStgring() +} + class OutputFilePort { - string _filename - number _fd + string __filename__ + symbol __type__ + fs() + internal() + close() + toString() +} + +class InputByteVectorPort { + symbol __type__ + Uint8Array __vector__ + integer __index__ + toString() + u8_ready() + peek_u8() + skip() + read_u8() + read_u8_vector(integer) +} + +class OutputByteVectorPort { + Uin8Array __buffer__ + symbol __type__ + write(any) + close() + write_u8(byte) + write_u8_vector(Uint8Array) + toString() + valueOf() } + +class InputByteVectorPort { + string __filename__ + toString() +} + +class OutputBinaryFilePort { + string __filename__ + symbol __type__ + write(any) + write_u8(byte) + write_u8_vector(Uint8Array) +} + class Formatter { string __code__ indent(object): number @@ -130,12 +200,14 @@ class LString { clone(): LString fill(LCharacter) } + class Worker { string url Worker worker rpc(method, params): Promise exec(code, [dynamic]): Promise } + class LCharacter { string __name__ string __char__ @@ -144,6 +216,7 @@ class LCharacter { toString(): string valueOf(): string } + class Lexer { string __input__ token(meta) @@ -159,6 +232,7 @@ class Lexer { next_token() static rules } + class Parser { Lexer __lexer__ Environent __env__ @@ -176,9 +250,11 @@ class Parser { is_ccomment(token) evaluate(code) } + class LSymbol { string __name__ } + class Environment { string __name__ Map __docs__ @@ -199,11 +275,13 @@ class Environment { merge(): Environment toString(): string } + class Values { any[] __values__ valueOf() toString() } + class Macro { string __doc__ string __name__ @@ -213,16 +291,19 @@ class Macro { invoke() toString() } + class Syntax { invoke() toString() } + class QuotedPromise { Promise __promise__ then() catch() valueOf() } + class Pair { any car any cdr @@ -238,6 +319,7 @@ class Pair { transform(Function) map(Function) } + class Interpreter { Environment __env__ get(symbol) diff --git a/assets/classDiagram.svg b/assets/classDiagram.svg index 173169a9..472ccbab 100644 --- a/assets/classDiagram.svg +++ b/assets/classDiagram.svg @@ -1 +1 @@ -<svg id="mermaid-1615135637099" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="596" style="max-width: 2819.2890625px;" viewBox="-20 -20 2819.2890625 596"><style>#mermaid-1615135637099{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1615135637099 .error-icon{fill:#552222;}#mermaid-1615135637099 .error-text{fill:#552222;stroke:#552222;}#mermaid-1615135637099 .edge-thickness-normal{stroke-width:2px;}#mermaid-1615135637099 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1615135637099 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1615135637099 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1615135637099 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1615135637099 .marker{fill:#333333;}#mermaid-1615135637099 .marker.cross{stroke:#333333;}#mermaid-1615135637099 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1615135637099 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1615135637099 g.classGroup text .title{font-weight:bolder;}#mermaid-1615135637099 .classTitle{font-weight:bolder;}#mermaid-1615135637099 .node rect,#mermaid-1615135637099 .node circle,#mermaid-1615135637099 .node ellipse,#mermaid-1615135637099 .node polygon,#mermaid-1615135637099 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1615135637099 .divider{stroke:#9370DB;stroke:1;}#mermaid-1615135637099 g.clickable{cursor:pointer;}#mermaid-1615135637099 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1615135637099 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1615135637099 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1615135637099 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1615135637099 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1615135637099 .dashed-line{stroke-dasharray:3;}#mermaid-1615135637099 #compositionStart,#mermaid-1615135637099 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #compositionEnd,#mermaid-1615135637099 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #dependencyStart,#mermaid-1615135637099 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #dependencyStart,#mermaid-1615135637099 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #extensionStart,#mermaid-1615135637099 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #extensionEnd,#mermaid-1615135637099 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #aggregationStart,#mermaid-1615135637099 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 #aggregationEnd,#mermaid-1615135637099 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615135637099 .edgeTerminals{font-size:11px;}#mermaid-1615135637099:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1615135637099 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(222.33203125,0 )"><rect x="0" y="0" width="98.828125" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="27.7734375">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="89.515625" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.9296875">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="89.515625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt __value__</tspan></text><line x1="0" y1="37" y2="37" x2="89.515625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(139.515625,293 )"><rect x="0" y="0" width="110.03125" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="33.109375">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="110.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __num__</tspan><tspan x="5" dy="10">LNumber __denom__</tspan></text><line x1="0" y1="47" y2="47" x2="110.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(299.546875,333 )"><rect x="0" y="0" width="98.828125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="34.7578125">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(448.375,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(588.796875,40 )"><rect x="0" y="0" width="82.203125" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.2421875">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="82.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Function _read</tspan></text><line x1="0" y1="37" y2="37" x2="82.203125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(589.40625,352 )"><rect x="0" y="0" width="80.984375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="80.984375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="80.984375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(594.28125,526 )"><rect x="0" y="0" width="71.234375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="71.234375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="71.234375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(803.44140625,70.5 )"><rect x="0" y="0" width="61.9375" height="67" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="61.9375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="61.9375"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(720.390625,346.5 )"><rect x="0" y="0" width="89.203125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="89.203125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] _buffer</tspan></text><line x1="0" y1="37" y2="37" x2="89.203125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(859.59375,341.5 )"><rect x="0" y="0" width="88.46875" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.5078125">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="88.46875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string _filename</tspan><tspan x="5" dy="10">number _fd</tspan></text><line x1="0" y1="47" y2="47" x2="88.46875"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Parser-11" class="classGroup" transform="translate(990.8984375,10 )"><rect x="0" y="0" width="106.875" height="188" class=" "></rect><text y="15" x="0"><tspan class="title" x="38.40625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="106.875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan><tspan x="5" dy="10">Environent __env__</tspan></text><line x1="0" y1="47" y2="47" x2="106.875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">resolve()</tspan><tspan x="5" dy="10">peek()</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">is_special(token)</tspan><tspan x="5" dy="10">is_builtin(token)</tspan><tspan x="5" dy="10">is_open(token)</tspan><tspan x="5" dy="10">is_close(token)</tspan><tspan x="5" dy="10">read_list()</tspan><tspan x="5" dy="10">read_value()</tspan><tspan x="5" dy="10">read_object()</tspan><tspan x="5" dy="10">is_ccomment(token)</tspan><tspan x="5" dy="10">evaluate(code)</tspan></text></g><g id="classid-Lexer-12" class="classGroup" transform="translate(998.0625,283 )"><rect x="0" y="0" width="92.546875" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="32.5">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="92.546875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __input__</tspan><tspan x="5" dy="10">static rules</tspan></text><line x1="0" y1="47" y2="47" x2="92.546875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">token(meta)</tspan><tspan x="5" dy="10">peek(meta)</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read_rest()</tspan><tspan x="5" dy="10">read_string(num)</tspan><tspan x="5" dy="10">peek_char()</tspan><tspan x="5" dy="10">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">match_rule()</tspan><tspan x="5" dy="10">next_token()</tspan></text></g><g id="classid-Macro-13" class="classGroup" transform="translate(1147.7734375,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-14" class="classGroup" transform="translate(1177.6015625,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-15" class="classGroup" transform="translate(1329.3203125,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-16" class="classGroup" transform="translate(1285.6015625,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-17" class="classGroup" transform="translate(1462.203125,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-18" class="classGroup" transform="translate(1466.85546875,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-19" class="classGroup" transform="translate(1556.19921875,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-20" class="classGroup" transform="translate(1685.5703125,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-21" class="classGroup" transform="translate(1707.3125,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-22" class="classGroup" transform="translate(1927.7421875,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-23" class="classGroup" transform="translate(2093.9921875,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-24" class="classGroup" transform="translate(2233.4453125,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-25" class="classGroup" transform="translate(2372.8984375,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-26" class="classGroup" transform="translate(2513.7109375,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-27" class="classGroup" transform="translate(2673.9609375,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">last_pair()</tspan><tspan x="5" dy="10">to_array()</tspan><tspan x="5" dy="10">to_object()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M222.33203125,132.08256896522053L192.736328125,148.90214080435044C163.140625,165.72171264348034,103.94921875,199.36085632174016,74.353515625,232.01376149420344C44.7578125,264.6666666666667,44.7578125,296.3333333333333,44.7578125,312.1666666666667L44.7578125,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M222.33203125,186.55425709515862L217.69856770833334,194.29521424596552C213.06510416666666,202.0361713967724,203.79817708333334,217.51808569838622,199.16471354166666,235.2590428491931C194.53125,253,194.53125,273,194.53125,283L194.53125,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,186.55425709515862L325.7936197916667,194.29521424596552C330.4270833333333,202.0361713967724,339.6940104166667,217.51808569838622,344.3274739583333,241.92570951585978C348.9609375,266.3333333333333,348.9609375,299.6666666666667,348.9609375,316.3333333333333L348.9609375,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,132.69489528565651L349.9485677083333,149.4124127380471C378.7369791666667,166.12993019043768,436.3138020833333,199.5649650952188,465.1022135416667,224.61581588094273C493.890625,249.66666666666666,493.890625,266.3333333333333,493.890625,274.6666666666667L493.890625,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,168L629.8984375,178.83333333333334C629.8984375,189.66666666666666,629.8984375,211.33333333333334,629.8984375,242C629.8984375,272.6666666666667,629.8984375,312.3333333333333,629.8984375,332.1666666666667L629.8984375,352" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M629.8984375,382L629.8984375,401.8333333333333C629.8984375,421.6666666666667,629.8984375,461.3333333333333,629.8984375,485.3333333333333C629.8984375,509.3333333333333,629.8984375,517.6666666666666,629.8984375,521.8333333333334L629.8984375,526" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M816.3830093265503,137.5L807.8178723554587,153.41666666666666C799.2527353843669,169.33333333333334,782.1224614421835,201.16666666666666,773.5573244710918,236C764.9921875,270.8333333333333,764.9921875,308.6666666666667,764.9921875,327.5833333333333L764.9921875,346.5" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M852.4373031734497,137.5L861.0024401445413,153.41666666666666C869.5675771156331,169.33333333333334,886.6978510578165,201.16666666666666,895.2629880289082,235.16666666666666C903.828125,269.1666666666667,903.828125,305.3333333333333,903.828125,323.4166666666667L903.828125,341.5" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M1044.3359375,198L1044.3359375,203.83333333333334C1044.3359375,209.66666666666666,1044.3359375,221.33333333333334,1044.3359375,235.5C1044.3359375,249.66666666666666,1044.3359375,266.3333333333333,1044.3359375,274.6666666666667L1044.3359375,283" id="edge8" class="relation" marker-start="url(#compositionStart)"></path><path d="M1206.6015625,158L1206.6015625,170.5C1206.6015625,183,1206.6015625,208,1206.6015625,238.08333333333334C1206.6015625,268.1666666666667,1206.6015625,303.3333333333333,1206.6015625,320.9166666666667L1206.6015625,338.5" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M1347.953125,119L1347.953125,138C1347.953125,157,1347.953125,195,1347.953125,224.83333333333334C1347.953125,254.66666666666666,1347.953125,276.3333333333333,1347.953125,287.1666666666667L1347.953125,298" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1520.9015867248063,148L1515.172546229005,162.16666666666666C1509.4435057332041,176.33333333333334,1497.9854247416022,204.66666666666666,1492.256384245801,238.66666666666666C1486.52734375,272.6666666666667,1486.52734375,312.3333333333333,1486.52734375,332.1666666666667L1486.52734375,352" id="edge11" class="relation" marker-start="url(#compositionStart)"></path><path d="M1556.4890382751937,148L1562.218078770995,162.16666666666666C1567.9471192667959,176.33333333333334,1579.4052002583978,204.66666666666666,1585.134240754199,236.91666666666666C1590.86328125,269.1666666666667,1590.86328125,305.3333333333333,1590.86328125,323.4166666666667L1590.86328125,341.5" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1781.65625,148L1781.65625,162.16666666666666C1781.65625,176.33333333333334,1781.65625,204.66666666666666,1781.65625,223C1781.65625,241.33333333333334,1781.65625,249.66666666666666,1781.65625,253.83333333333334L1781.65625,258" id="edge13" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file +<svg id="mermaid-1615304830772" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="654" style="max-width: 3224.4921875px;" viewBox="-20 -20 3224.4921875 654"><style>#mermaid-1615304830772{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-1615304830772 .error-icon{fill:#552222;}#mermaid-1615304830772 .error-text{fill:#552222;stroke:#552222;}#mermaid-1615304830772 .edge-thickness-normal{stroke-width:2px;}#mermaid-1615304830772 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-1615304830772 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-1615304830772 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-1615304830772 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-1615304830772 .marker{fill:#333333;}#mermaid-1615304830772 .marker.cross{stroke:#333333;}#mermaid-1615304830772 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-1615304830772 g.classGroup text{fill:#9370DB;fill:#131300;stroke:none;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:10px;}#mermaid-1615304830772 g.classGroup text .title{font-weight:bolder;}#mermaid-1615304830772 .classTitle{font-weight:bolder;}#mermaid-1615304830772 .node rect,#mermaid-1615304830772 .node circle,#mermaid-1615304830772 .node ellipse,#mermaid-1615304830772 .node polygon,#mermaid-1615304830772 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-1615304830772 .divider{stroke:#9370DB;stroke:1;}#mermaid-1615304830772 g.clickable{cursor:pointer;}#mermaid-1615304830772 g.classGroup rect{fill:#ECECFF;stroke:#9370DB;}#mermaid-1615304830772 g.classGroup line{stroke:#9370DB;stroke-width:1;}#mermaid-1615304830772 .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5;}#mermaid-1615304830772 .classLabel .label{fill:#9370DB;font-size:10px;}#mermaid-1615304830772 .relation{stroke:#333333;stroke-width:1;fill:none;}#mermaid-1615304830772 .dashed-line{stroke-dasharray:3;}#mermaid-1615304830772 #compositionStart,#mermaid-1615304830772 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #compositionEnd,#mermaid-1615304830772 .composition{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #dependencyStart,#mermaid-1615304830772 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #dependencyStart,#mermaid-1615304830772 .dependency{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #extensionStart,#mermaid-1615304830772 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #extensionEnd,#mermaid-1615304830772 .extension{fill:#333333 !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #aggregationStart,#mermaid-1615304830772 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 #aggregationEnd,#mermaid-1615304830772 .aggregation{fill:#ECECFF !important;stroke:#333333 !important;stroke-width:1;}#mermaid-1615304830772 .edgeTerminals{font-size:11px;}#mermaid-1615304830772:root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-1615304830772 class{fill:apa;}</style><g></g><defs><marker id="extensionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 1,7 L18,13 V 1 Z"></path></marker></defs><defs><marker id="extensionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 1,1 V 13 L18,7 Z"></path></marker></defs><defs><marker id="compositionStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="compositionEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="aggregationEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyStart" class="extension" refX="0" refY="7" markerWidth="190" markerHeight="240" orient="auto"><path d="M 5,7 L9,13 L1,7 L9,1 Z"></path></marker></defs><defs><marker id="dependencyEnd" refX="19" refY="7" markerWidth="20" markerHeight="28" orient="auto"><path d="M 18,7 L9,13 L14,7 L9,1 Z"></path></marker></defs><g id="classid-LNumber-0" class="classGroup" transform="translate(222.33203125,0 )"><rect x="0" y="0" width="98.828125" height="208" class=" "></rect><text y="15" x="0"><tspan class="title" x="27.7734375">LNumber</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">isFloat()</tspan><tspan x="5" dy="10">isNumber()</tspan><tspan x="5" dy="10">isComplex()</tspan><tspan x="5" dy="10">isRational()</tspan><tspan x="5" dy="10">isNative()</tspan><tspan x="5" dy="10">isBigInteger()</tspan><tspan x="5" dy="10">isBN()</tspan><tspan x="5" dy="10">getType()</tspan><tspan x="5" dy="10">coerce()</tspan><tspan x="5" dy="10">op()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">isOdd()</tspan><tspan x="5" dy="10">isEven()</tspan><tspan x="5" dy="10">cmp()</tspan></text></g><g id="classid-LBigInteger-1" class="classGroup" transform="translate(0,328 )"><rect x="0" y="0" width="89.515625" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.9296875">LBigInteger</tspan></text><line x1="0" y1="21" y2="21" x2="89.515625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">BigInt __value__</tspan></text><line x1="0" y1="37" y2="37" x2="89.515625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">gcd()</tspan><tspan x="5" dy="10">sqrt()</tspan></text></g><g id="classid-LRational-2" class="classGroup" transform="translate(139.515625,293 )"><rect x="0" y="0" width="110.03125" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="33.109375">LRational</tspan></text><line x1="0" y1="21" y2="21" x2="110.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __num__</tspan><tspan x="5" dy="10">LNumber __denom__</tspan></text><line x1="0" y1="47" y2="47" x2="110.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">pow()</tspan><tspan x="5" dy="10">abs()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LFloat-3" class="classGroup" transform="translate(299.546875,333 )"><rect x="0" y="0" width="98.828125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="34.7578125">LFloat</tspan></text><line x1="0" y1="21" y2="21" x2="98.828125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Number __value__</tspan></text><line x1="0" y1="37" y2="37" x2="98.828125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toRational()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-LComplex-4" class="classGroup" transform="translate(448.375,283 )"><rect x="0" y="0" width="91.03125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3046875">LComplex</tspan></text><line x1="0" y1="21" y2="21" x2="91.03125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">LNumber __im__</tspan><tspan x="5" dy="10">LNumber __re__</tspan></text><line x1="0" y1="47" y2="47" x2="91.03125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">sqrt()</tspan><tspan x="5" dy="10">toRational()</tspan><tspan x="5" dy="10">add()</tspan><tspan x="5" dy="10">factor()</tspan><tspan x="5" dy="10">modulus()</tspan><tspan x="5" dy="10">sqrt()</tspan><tspan x="5" dy="10">div()</tspan><tspan x="5" dy="10">sub()</tspan><tspan x="5" dy="10">mul()</tspan><tspan x="5" dy="10">cmp()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputPort-5" class="classGroup" transform="translate(665.9609375,40 )"><rect x="0" y="0" width="95.484375" height="128" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.8828125">InputPort</tspan></text><line x1="0" y1="21" y2="21" x2="95.484375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Parser __parser__</tspan></text><line x1="0" y1="37" y2="37" x2="95.484375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">char_ready()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputStringPort-6" class="classGroup" transform="translate(589.40625,333 )"><rect x="0" y="0" width="90.84375" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="9.9296875">InputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="90.84375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">symbol __type__</tspan></text><line x1="0" y1="37" y2="37" x2="90.84375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">char_ready()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputFilePort-7" class="classGroup" transform="translate(582.625,541 )"><rect x="0" y="0" width="104.40625" height="58" class=" "></rect><text y="15" x="0"><tspan class="title" x="21.5859375">InputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="104.40625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __filename__</tspan></text><line x1="0" y1="37" y2="37" x2="104.40625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toStgring()</tspan></text></g><g id="classid-OutputPort-8" class="classGroup" transform="translate(1061.78125,60 )"><rect x="0" y="0" width="90.84375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.453125">OutputPort</tspan></text><line x1="0" y1="21" y2="21" x2="90.84375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">symbol __type__</tspan></text><line x1="0" y1="37" y2="37" x2="90.84375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">write()</tspan><tspan x="5" dy="10">is_open()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputStringPort-9" class="classGroup" transform="translate(904.90625,323 )"><rect x="0" y="0" width="100.09375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="10.4453125">OutputStringPort</tspan></text><line x1="0" y1="21" y2="21" x2="100.09375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string[] __buffer__</tspan><tspan x="5" dy="10">symbol __type__</tspan></text><line x1="0" y1="47" y2="47" x2="100.09375"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">write()</tspan><tspan x="5" dy="10">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputFilePort-10" class="classGroup" transform="translate(1055,318 )"><rect x="0" y="0" width="104.40625" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.4765625">OutputFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="104.40625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __filename__</tspan><tspan x="5" dy="10">symbol __type__</tspan></text><line x1="0" y1="47" y2="47" x2="104.40625"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">fs()</tspan><tspan x="5" dy="10">internal()</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-OutputByteVectorPort-11" class="classGroup" transform="translate(1209.40625,308 )"><rect x="0" y="0" width="143.859375" height="118" class=" "></rect><text y="15" x="0"><tspan class="title" x="20.2421875">OutputByteVectorPort</tspan></text><line x1="0" y1="21" y2="21" x2="143.859375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Uin8Array __buffer__</tspan><tspan x="5" dy="10">symbol __type__</tspan></text><line x1="0" y1="47" y2="47" x2="143.859375"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">write(any)</tspan><tspan x="5" dy="10">close()</tspan><tspan x="5" dy="10">write_u8(byte)</tspan><tspan x="5" dy="10">write_u8_vector(Uint8Array)</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-InputByteVectorPort-12" class="classGroup" transform="translate(730.25,293 )"><rect x="0" y="0" width="124.65625" height="148" class=" "></rect><text y="15" x="0"><tspan class="title" x="14.75">InputByteVectorPort</tspan></text><line x1="0" y1="21" y2="21" x2="124.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">symbol __type__</tspan><tspan x="5" dy="10">Uint8Array __vector__</tspan><tspan x="5" dy="10">integer __index__</tspan><tspan x="5" dy="10">string __filename__</tspan></text><line x1="0" y1="67" y2="67" x2="124.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">u8_ready()</tspan><tspan x="5" dy="10">peek_u8()</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read_u8()</tspan><tspan x="5" dy="10">read_u8_vector(integer)</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-InputBinaryFilePort-13" class="classGroup" transform="translate(740.375,541 )"><rect x="0" y="0" width="104.40625" height="58" class=" "></rect><text y="15" x="0"><tspan class="title" x="6.6953125">InputBinaryFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="104.40625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __filename__</tspan></text><line x1="0" y1="37" y2="37" x2="104.40625"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">toString()</tspan></text></g><g id="classid-OutputBinaryFilePort-14" class="classGroup" transform="translate(1035.2734375,526 )"><rect x="0" y="0" width="143.859375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="22.3125">OutputBinaryFilePort</tspan></text><line x1="0" y1="21" y2="21" x2="143.859375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __filename__</tspan><tspan x="5" dy="10">symbol __type__</tspan></text><line x1="0" y1="47" y2="47" x2="143.859375"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">write(any)</tspan><tspan x="5" dy="10">write_u8(byte)</tspan><tspan x="5" dy="10">write_u8_vector(Uint8Array)</tspan></text></g><g id="classid-Parser-15" class="classGroup" transform="translate(1396.1015625,10 )"><rect x="0" y="0" width="106.875" height="188" class=" "></rect><text y="15" x="0"><tspan class="title" x="38.40625">Parser</tspan></text><line x1="0" y1="21" y2="21" x2="106.875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Lexer __lexer__</tspan><tspan x="5" dy="10">Environent __env__</tspan></text><line x1="0" y1="47" y2="47" x2="106.875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">resolve()</tspan><tspan x="5" dy="10">peek()</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read()</tspan><tspan x="5" dy="10">is_special(token)</tspan><tspan x="5" dy="10">is_builtin(token)</tspan><tspan x="5" dy="10">is_open(token)</tspan><tspan x="5" dy="10">is_close(token)</tspan><tspan x="5" dy="10">read_list()</tspan><tspan x="5" dy="10">read_value()</tspan><tspan x="5" dy="10">read_object()</tspan><tspan x="5" dy="10">is_ccomment(token)</tspan><tspan x="5" dy="10">evaluate(code)</tspan></text></g><g id="classid-Lexer-16" class="classGroup" transform="translate(1403.265625,283 )"><rect x="0" y="0" width="92.546875" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="32.5">Lexer</tspan></text><line x1="0" y1="21" y2="21" x2="92.546875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __input__</tspan><tspan x="5" dy="10">static rules</tspan></text><line x1="0" y1="47" y2="47" x2="92.546875"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">token(meta)</tspan><tspan x="5" dy="10">peek(meta)</tspan><tspan x="5" dy="10">skip()</tspan><tspan x="5" dy="10">read_line()</tspan><tspan x="5" dy="10">read_rest()</tspan><tspan x="5" dy="10">read_string(num)</tspan><tspan x="5" dy="10">peek_char()</tspan><tspan x="5" dy="10">read_char()</tspan><tspan x="5" dy="10">skip_char()</tspan><tspan x="5" dy="10">match_rule()</tspan><tspan x="5" dy="10">next_token()</tspan></text></g><g id="classid-Macro-17" class="classGroup" transform="translate(1552.9765625,50 )"><rect x="0" y="0" width="117.65625" height="108" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.7421875">Macro</tspan></text><line x1="0" y1="21" y2="21" x2="117.65625"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __doc__</tspan><tspan x="5" dy="10">string __name__</tspan><tspan x="5" dy="10">boolean __defmacro__</tspan><tspan x="5" dy="10">Function __fn__</tspan></text><line x1="0" y1="67" y2="67" x2="117.65625"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">defmacro()</tspan><tspan x="5" dy="10">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Syntax-18" class="classGroup" transform="translate(1582.8046875,338.5 )"><rect x="0" y="0" width="58" height="57" class=" "></rect><text y="15" x="0"><tspan class="title" x="13.171875">Syntax</tspan></text><line x1="0" y1="21" y2="21" x2="58"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="58"></line><text x="5" y="41" fill="white" class="classText"><tspan x="5">invoke()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-String-19" class="classGroup" transform="translate(1734.5234375,89 )"><rect x="0" y="0" width="37.265625" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">String</tspan></text><line x1="0" y1="21" y2="21" x2="37.265625"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="37.265625"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-LString-20" class="classGroup" transform="translate(1690.8046875,298 )"><rect x="0" y="0" width="124.703125" height="138" class=" "></rect><text y="15" x="0"><tspan class="title" x="45.953125">LString</tspan></text><line x1="0" y1="21" y2="21" x2="124.703125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __string__</tspan><tspan x="5" dy="10">number length</tspan></text><line x1="0" y1="47" y2="47" x2="124.703125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toString()</tspan><tspan x="5" dy="10">get(number)</tspan><tspan x="5" dy="10">cmp(string)</tspan><tspan x="5" dy="10">lower()</tspan><tspan x="5" dy="10">upper()</tspan><tspan x="5" dy="10">set(number, LCharacter)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">fill(LCharacter)</tspan></text></g><g id="classid-Formatter-21" class="classGroup" transform="translate(1867.40625,60 )"><rect x="0" y="0" width="152.984375" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="52.5390625">Formatter</tspan></text><line x1="0" y1="21" y2="21" x2="152.984375"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __code__</tspan></text><line x1="0" y1="37" y2="37" x2="152.984375"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">indent(object)</tspan><tspan x="5" dy="10">exception_shift(token, object)</tspan><tspan x="5" dy="10">break()</tspan><tspan x="5" dy="10">format()</tspan></text></g><g id="classid-Ahead-22" class="classGroup" transform="translate(1872.05859375,352 )"><rect x="0" y="0" width="39.34375" height="30" class=" "></rect><text y="15" x="0"><tspan class="title" x="5">Ahead</tspan></text><line x1="0" y1="21" y2="21" x2="39.34375"></line><text x="5" y="31" fill="white" class="classText"></text><line x1="0" y1="26" y2="26" x2="39.34375"></line><text x="5" y="41" fill="white" class="classText"></text></g><g id="classid-Pattern-23" class="classGroup" transform="translate(1961.40234375,341.5 )"><rect x="0" y="0" width="69.328125" height="51" class=" "></rect><text y="15" x="0"><tspan class="title" x="17.3203125">Pattern</tspan></text><line x1="0" y1="21" y2="21" x2="69.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">rule pattern</tspan><tspan x="5" dy="10">string flag</tspan></text><line x1="0" y1="47" y2="47" x2="69.328125"></line><text x="5" y="62" fill="white" class="classText"></text></g><g id="classid-Interpreter-24" class="classGroup" transform="translate(2090.7734375,60 )"><rect x="0" y="0" width="192.171875" height="88" class=" "></rect><text y="15" x="0"><tspan class="title" x="69.46875">Interpreter</tspan></text><line x1="0" y1="21" y2="21" x2="192.171875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Environment __env__</tspan></text><line x1="0" y1="37" y2="37" x2="192.171875"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">get(symbol)</tspan><tspan x="5" dy="10">set(symbol, value)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">exec(code, dynamic = false, env = null)</tspan></text></g><g id="classid-Environment-25" class="classGroup" transform="translate(2112.515625,258 )"><rect x="0" y="0" width="148.6875" height="218" class=" "></rect><text y="15" x="0"><tspan class="title" x="44.21875">Environment</tspan></text><line x1="0" y1="21" y2="21" x2="148.6875"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">Map __docs__</tspan><tspan x="5" dy="10">Object __env__</tspan><tspan x="5" dy="10">Environment __parent__</tspan></text><line x1="0" y1="67" y2="67" x2="148.6875"></line><text x="5" y="82" fill="white" class="classText"><tspan x="5">list()</tspan><tspan x="5" dy="10">uset(name)</tspan><tspan x="5" dy="10">inherit(name, object)</tspan><tspan x="5" dy="10">doc(name, value = null)</tspan><tspan x="5" dy="10">get(symbol, options)</tspan><tspan x="5" dy="10">set(symbol, value, doc = null)</tspan><tspan x="5" dy="10">constant(name, value)</tspan><tspan x="5" dy="10">has(string)</tspan><tspan x="5" dy="10">ref(string)</tspan><tspan x="5" dy="10">parents()</tspan><tspan x="5" dy="10">newFrame(Function, args)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">merge()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-Worker-26" class="classGroup" transform="translate(2332.9453125,65 )"><rect x="0" y="0" width="116.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="40.7109375">Worker</tspan></text><line x1="0" y1="21" y2="21" x2="116.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string url</tspan><tspan x="5" dy="10">Worker worker</tspan></text><line x1="0" y1="47" y2="47" x2="116.25"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">rpc(method, params)</tspan><tspan x="5" dy="10">exec(code, [dynamic])</tspan></text></g><g id="classid-LCharacter-27" class="classGroup" transform="translate(2499.1953125,55 )"><rect x="0" y="0" width="89.453125" height="98" class=" "></rect><text y="15" x="0"><tspan class="title" x="18.7109375">LCharacter</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan><tspan x="5" dy="10">string __char__</tspan></text><line x1="0" y1="47" y2="47" x2="89.453125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">toUpperCase()</tspan><tspan x="5" dy="10">toLowerCase()</tspan><tspan x="5" dy="10">toString()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-LSymbol-28" class="classGroup" transform="translate(2638.6484375,83.5 )"><rect x="0" y="0" width="89.453125" height="41" class=" "></rect><text y="15" x="0"><tspan class="title" x="25.203125">LSymbol</tspan></text><line x1="0" y1="21" y2="21" x2="89.453125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">string __name__</tspan></text><line x1="0" y1="37" y2="37" x2="89.453125"></line><text x="5" y="52" fill="white" class="classText"></text></g><g id="classid-Values-29" class="classGroup" transform="translate(2778.1015625,70 )"><rect x="0" y="0" width="90.8125" height="68" class=" "></rect><text y="15" x="0"><tspan class="title" x="30.546875">Values</tspan></text><line x1="0" y1="21" y2="21" x2="90.8125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any[] __values__</tspan></text><line x1="0" y1="37" y2="37" x2="90.8125"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">valueOf()</tspan><tspan x="5" dy="10">toString()</tspan></text></g><g id="classid-QuotedPromise-30" class="classGroup" transform="translate(2918.9140625,65 )"><rect x="0" y="0" width="110.25" height="78" class=" "></rect><text y="15" x="0"><tspan class="title" x="19.1953125">QuotedPromise</tspan></text><line x1="0" y1="21" y2="21" x2="110.25"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">Promise __promise__</tspan></text><line x1="0" y1="37" y2="37" x2="110.25"></line><text x="5" y="52" fill="white" class="classText"><tspan x="5">then()</tspan><tspan x="5" dy="10">catch()</tspan><tspan x="5" dy="10">valueOf()</tspan></text></g><g id="classid-Pair-31" class="classGroup" transform="translate(3079.1640625,20 )"><rect x="0" y="0" width="105.328125" height="168" class=" "></rect><text y="15" x="0"><tspan class="title" x="43.3046875">Pair</tspan></text><line x1="0" y1="21" y2="21" x2="105.328125"></line><text x="5" y="31" fill="white" class="classText"><tspan x="5">any car</tspan><tspan x="5" dy="10">any cdr</tspan></text><line x1="0" y1="47" y2="47" x2="105.328125"></line><text x="5" y="62" fill="white" class="classText"><tspan x="5">flatten()</tspan><tspan x="5" dy="10">length()</tspan><tspan x="5" dy="10">find(any)</tspan><tspan x="5" dy="10">clone()</tspan><tspan x="5" dy="10">last_pair()</tspan><tspan x="5" dy="10">to_array()</tspan><tspan x="5" dy="10">to_object()</tspan><tspan x="5" dy="10">reduce(Function)</tspan><tspan x="5" dy="10">reverse()</tspan><tspan x="5" dy="10">transform(Function)</tspan><tspan x="5" dy="10">map(Function)</tspan></text></g><path d="M222.33203125,132.08256896522053L192.736328125,148.90214080435044C163.140625,165.72171264348034,103.94921875,199.36085632174016,74.353515625,232.01376149420344C44.7578125,264.6666666666667,44.7578125,296.3333333333333,44.7578125,312.1666666666667L44.7578125,328" id="edge0" class="relation" marker-start="url(#extensionStart)"></path><path d="M222.33203125,186.55425709515862L217.69856770833334,194.29521424596552C213.06510416666666,202.0361713967724,203.79817708333334,217.51808569838622,199.16471354166666,235.2590428491931C194.53125,253,194.53125,273,194.53125,283L194.53125,293" id="edge1" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,186.55425709515862L325.7936197916667,194.29521424596552C330.4270833333333,202.0361713967724,339.6940104166667,217.51808569838622,344.3274739583333,241.92570951585978C348.9609375,266.3333333333333,348.9609375,299.6666666666667,348.9609375,316.3333333333333L348.9609375,333" id="edge2" class="relation" marker-start="url(#extensionStart)"></path><path d="M321.16015625,132.69489528565651L349.9485677083333,149.4124127380471C378.7369791666667,166.12993019043768,436.3138020833333,199.5649650952188,465.1022135416667,224.61581588094273C493.890625,249.66666666666666,493.890625,266.3333333333333,493.890625,274.6666666666667L493.890625,283" id="edge3" class="relation" marker-start="url(#extensionStart)"></path><path d="M674.5713420542636,168L667.9474725452196,178.83333333333334C661.3236030361758,189.66666666666666,648.0758640180878,211.33333333333334,641.4519945090439,238.83333333333334C634.828125,266.3333333333333,634.828125,299.6666666666667,634.828125,316.3333333333333L634.828125,333" id="edge4" class="relation" marker-start="url(#extensionStart)"></path><path d="M634.828125,401L634.828125,417.6666666666667C634.828125,434.3333333333333,634.828125,467.6666666666667,634.828125,491C634.828125,514.3333333333334,634.828125,527.6666666666666,634.828125,534.3333333333334L634.828125,541" id="edge5" class="relation" marker-start="url(#extensionStart)"></path><path d="M1061.78125,142.48552955665025L1043.9765625,157.57127463054186C1026.171875,172.6570197044335,990.5625,202.82850985221674,972.7578125,232.91425492610838C954.953125,263,954.953125,293,954.953125,308L954.953125,323" id="edge6" class="relation" marker-start="url(#extensionStart)"></path><path d="M1107.203125,148L1107.203125,162.16666666666666C1107.203125,176.33333333333334,1107.203125,204.66666666666666,1107.203125,233C1107.203125,261.3333333333333,1107.203125,289.6666666666667,1107.203125,303.8333333333333L1107.203125,318" id="edge7" class="relation" marker-start="url(#extensionStart)"></path><path d="M1152.625,137.64915429135448L1174.0768229166667,153.54096190946208C1195.5286458333333,169.43276952756966,1238.4322916666667,201.21638476378484,1259.8841145833333,229.60819238189242C1281.3359375,258,1281.3359375,283,1281.3359375,295.5L1281.3359375,308" id="edge8" class="relation" marker-start="url(#extensionStart)"></path><path d="M752.8349079457364,168L759.4587774547804,178.83333333333334C766.0826469638242,189.66666666666666,779.3303859819122,211.33333333333334,785.9542554909561,232.16666666666666C792.578125,253,792.578125,273,792.578125,283L792.578125,293" id="edge9" class="relation" marker-start="url(#extensionStart)"></path><path d="M792.578125,441L792.578125,451C792.578125,461,792.578125,481,792.578125,497.6666666666667C792.578125,514.3333333333334,792.578125,527.6666666666666,792.578125,534.3333333333334L792.578125,541" id="edge10" class="relation" marker-start="url(#extensionStart)"></path><path d="M1107.203125,416L1107.203125,430.1666666666667C1107.203125,444.3333333333333,1107.203125,472.6666666666667,1107.203125,491C1107.203125,509.3333333333333,1107.203125,517.6666666666666,1107.203125,521.8333333333334L1107.203125,526" id="edge11" class="relation" marker-start="url(#extensionStart)"></path><path d="M1449.5390625,198L1449.5390625,203.83333333333334C1449.5390625,209.66666666666666,1449.5390625,221.33333333333334,1449.5390625,235.5C1449.5390625,249.66666666666666,1449.5390625,266.3333333333333,1449.5390625,274.6666666666667L1449.5390625,283" id="edge12" class="relation" marker-start="url(#compositionStart)"></path><path d="M1611.8046875,158L1611.8046875,170.5C1611.8046875,183,1611.8046875,208,1611.8046875,238.08333333333334C1611.8046875,268.1666666666667,1611.8046875,303.3333333333333,1611.8046875,320.9166666666667L1611.8046875,338.5" id="edge13" class="relation" marker-start="url(#extensionStart)"></path><path d="M1753.15625,119L1753.15625,138C1753.15625,157,1753.15625,195,1753.15625,224.83333333333334C1753.15625,254.66666666666666,1753.15625,276.3333333333333,1753.15625,287.1666666666667L1753.15625,298" id="edge14" class="relation" marker-start="url(#extensionStart)"></path><path d="M1926.1047117248063,148L1920.375671229005,162.16666666666666C1914.6466307332041,176.33333333333334,1903.1885497416022,204.66666666666666,1897.459509245801,238.66666666666666C1891.73046875,272.6666666666667,1891.73046875,312.3333333333333,1891.73046875,332.1666666666667L1891.73046875,352" id="edge15" class="relation" marker-start="url(#compositionStart)"></path><path d="M1961.6921632751937,148L1967.421203770995,162.16666666666666C1973.1502442667959,176.33333333333334,1984.6083252583978,204.66666666666666,1990.337365754199,236.91666666666666C1996.06640625,269.1666666666667,1996.06640625,305.3333333333333,1996.06640625,323.4166666666667L1996.06640625,341.5" id="edge16" class="relation" marker-start="url(#compositionStart)"></path><path d="M2186.859375,148L2186.859375,162.16666666666666C2186.859375,176.33333333333334,2186.859375,204.66666666666666,2186.859375,223C2186.859375,241.33333333333334,2186.859375,249.66666666666666,2186.859375,253.83333333333334L2186.859375,258" id="edge17" class="relation" marker-start="url(#compositionStart)"></path></svg> \ No newline at end of file From f4eac9b38a99006c5d215e59aa2a402f8f2cabb4 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 15:15:36 +0100 Subject: [PATCH 098/109] fix error when indexedBD is not available --- dist/std.min.scm | 3 ++- dist/std.scm | 30 +++++++++++++++++++++++++++++- lib/bootstrap.scm | 30 +++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index bbf083aa..a0cfa2de 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -99,7 +99,8 @@ (define-macro (%not-implemented name) "(not-implemented name)\u000A\u000AReturns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ")\u000A\u000AThis function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented")))))))) (define-macro (%make-env name . names) "(%make-env name f1 f2 ...)\u000A\u000ACreate new Environment with given name and defined symbols in it from global env.\u000AIf given function name f1 f2 ... don't exists, it will define function that\u000Athrow exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name)))) (define Y (lambda (h) "(Y f)\u000A\u000A _ __ __ _ _ _ _ __ __ _ _ _\u000A / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\\u000A+ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + +\u000A| \\ / | \\ \\ | | |__ | | \\ / | |__ | | |\u000A| | | | / \\ | | __| | | | | | __| | | |\u000A| | | | / /\\ \\ | | | | | | | | | | | |\u000A+ |_| + /_/ \\_\\ + |_| + + |_| |_| + + +\u000A \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args))))))) -(let* ((fs (cond ((eq? self global) (require "fs")) ((not (null? self.BrowserFS)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e))))))))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) (. (BrowserFS.BFSRequire "buffer") (quote Buffer)))))) (let ((internal (lips.env.get (quote **internal-env**)))) (if (not (null? Buffer)) (internal.set "Buffer" Buffer)) (if (not (null? fs)) (internal.set "fs" fs)))) +(define (indexed-db?) "(indexed-db?)\u000A\u000AFunction test if indexedDB is available." (let* ((any (lambda args (let iter ((args args)) (if (null? args) #f (if (not (null? (car args))) (car args) (iter (cdr args))))))) (indexedDB (any window.indexedDB window.indexedDB window.mozIndexedDB window.webkitIndexedDB))) (if (not (null? indexedDB)) (try (begin (window.indexedDB.open "MyTestDatabase" 3) #t) (catch (e) #f)) #f))) +(let* ((fs (cond ((eq? self global) (require "fs")) ((and (not (null? self.BrowserFS)) (indexed-db?)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e))))))))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) (. (BrowserFS.BFSRequire "buffer") (quote Buffer)))))) (let ((internal (lips.env.get (quote **internal-env**)))) (if (not (null? Buffer)) (internal.set "Buffer" Buffer)) (if (not (null? fs)) (internal.set "fs" fs)))) (define (environment? obj) "(environment? obj)\u000A\u000AFunction check if object is LIPS environment." (instanceof lips.Environment obj)) (define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path)\u000A\u000ARead file from url or file system. If binary is false it will return\u000Astring that contain all the content. For HTTP requests, If binary\u000Ais false it will: when in browser return ArrayBuffer and in Node\u000Ait will return Buffer object. When reading from file system\u000Ain both cases it will return Buffer objects.\u000A\u000AThe code that use those function, in binary mode, need to check\u000Aif the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) (define %read-binary-file (curry %read-file #t)) diff --git a/dist/std.scm b/dist/std.scm index 42ace5df..5a6a2758 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1226,9 +1226,37 @@ (lambda (g) (h (lambda args (apply (g g) args))))))) +;; ----------------------------------------------------------------------------- +(define (indexed-db?) + "(indexed-db?) + + Function test if indexedDB is available." + (let* ((any (lambda args + (let iter ((args args)) + (if (null? args) + false + (if (not (null? (car args))) + (car args) + (iter (cdr args))))))) + (indexedDB (any window.indexedDB + window.indexedDB + window.mozIndexedDB + window.webkitIndexedDB))) + (if (not (null? indexedDB)) + (try + (begin + ;; open will fail in about:blank + (window.indexedDB.open "MyTestDatabase" 3) + true) + (catch (e) + false)) + false))) + +;; ----------------------------------------------------------------------------- +;; init internal fs for LIPS Scheme Input/Output functions ;; ----------------------------------------------------------------------------- (let* ((fs (cond ((eq? self global) (require "fs")) - ((not (null? self.BrowserFS)) + ((and (not (null? self.BrowserFS)) (indexed-db?)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:fs "IndexedDB" diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index e266b06a..ea115850 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1226,9 +1226,37 @@ (lambda (g) (h (lambda args (apply (g g) args))))))) +;; ----------------------------------------------------------------------------- +(define (indexed-db?) + "(indexed-db?) + + Function test if indexedDB is available." + (let* ((any (lambda args + (let iter ((args args)) + (if (null? args) + false + (if (not (null? (car args))) + (car args) + (iter (cdr args))))))) + (indexedDB (any window.indexedDB + window.indexedDB + window.mozIndexedDB + window.webkitIndexedDB))) + (if (not (null? indexedDB)) + (try + (begin + ;; open will fail in about:blank + (window.indexedDB.open "MyTestDatabase" 3) + true) + (catch (e) + false)) + false))) + +;; ----------------------------------------------------------------------------- +;; init internal fs for LIPS Scheme Input/Output functions ;; ----------------------------------------------------------------------------- (let* ((fs (cond ((eq? self global) (require "fs")) - ((not (null? self.BrowserFS)) + ((and (not (null? self.BrowserFS)) (indexed-db?)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:fs "IndexedDB" From c831c975263b768b40628d54dff82db1b25f4432 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 15:21:34 +0100 Subject: [PATCH 099/109] add warning when BrowserFS can't be initlized --- README.md | 4 ++-- dist/std.min.scm | 2 +- dist/std.scm | 6 +++++- lib/bootstrap.scm | 6 +++++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 64648954..7ac38e4b 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&ea85de0c0d7205ca2e8f48ba8a556efb465dd079)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&37d92ca40f03da1d26598c0ee49db9a2)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&f4eac9b38a99006c5d215e59aa2a402f8f2cabb4)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7fcdb640683e8c1d9f2ebaf039e933d2)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/std.min.scm b/dist/std.min.scm index a0cfa2de..f49e2b8e 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -100,7 +100,7 @@ (define-macro (%make-env name . names) "(%make-env name f1 f2 ...)\u000A\u000ACreate new Environment with given name and defined symbols in it from global env.\u000AIf given function name f1 f2 ... don't exists, it will define function that\u000Athrow exception that function is not yet implemented." (quasiquote (new lips.Environment (alist->object (list (unquote-splicing (map (lambda (name) (quasiquote (cons (quote (unquote name)) (unquote (let ((ref (lips.env.ref name))) (if (null? ref) (quasiquote (%not-implemented (unquote name))) (quasiquote (lips.env.get (quote (unquote name)))))))))) names)))) null (unquote name)))) (define Y (lambda (h) "(Y f)\u000A\u000A _ __ __ _ _ _ _ __ __ _ _ _\u000A / \\ \\ / / / __ / ____ \\ / \\ \\ / / ____ \\ \\ \\\u000A+ \\ v / + \\ \\ + / ___| + + \\ v / / ___| + + +\u000A| \\ / | \\ \\ | | |__ | | \\ / | |__ | | |\u000A| | | | / \\ | | __| | | | | | __| | | |\u000A| | | | / /\\ \\ | | | | | | | | | | | |\u000A+ |_| + /_/ \\_\\ + |_| + + |_| |_| + + +\u000A \\_ \\_ \\_ _/ \\_ _/ _/ _/" ((lambda (x) (x x)) (lambda (g) (h (lambda args (apply (g g) args))))))) (define (indexed-db?) "(indexed-db?)\u000A\u000AFunction test if indexedDB is available." (let* ((any (lambda args (let iter ((args args)) (if (null? args) #f (if (not (null? (car args))) (car args) (iter (cdr args))))))) (indexedDB (any window.indexedDB window.indexedDB window.mozIndexedDB window.webkitIndexedDB))) (if (not (null? indexedDB)) (try (begin (window.indexedDB.open "MyTestDatabase" 3) #t) (catch (e) #f)) #f))) -(let* ((fs (cond ((eq? self global) (require "fs")) ((and (not (null? self.BrowserFS)) (indexed-db?)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e))))))))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) (. (BrowserFS.BFSRequire "buffer") (quote Buffer)))))) (let ((internal (lips.env.get (quote **internal-env**)))) (if (not (null? Buffer)) (internal.set "Buffer" Buffer)) (if (not (null? fs)) (internal.set "fs" fs)))) +(let* ((fs (cond ((eq? self global) (require "fs")) ((and (not (null? self.BrowserFS)) (indexed-db?)) (new Promise (lambda (resolve reject) (BrowserFS.configure &(:options &() :fs "IndexedDB") (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) (reject e))))))) ((not (null? self.BrowserFS)) (console.warn (string-append "BrowserFS not initilalized " "IndexedDB is not available")) ()))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) (. (BrowserFS.BFSRequire "buffer") (quote Buffer)))))) (let ((internal (lips.env.get (quote **internal-env**)))) (if (not (null? Buffer)) (internal.set "Buffer" Buffer)) (if (not (null? fs)) (internal.set "fs" fs)))) (define (environment? obj) "(environment? obj)\u000A\u000AFunction check if object is LIPS environment." (instanceof lips.Environment obj)) (define %read-file (let ((read-file #f) (fetch-url #f)) (lambda (binary path) "(%read-file binary path)\u000A\u000ARead file from url or file system. If binary is false it will return\u000Astring that contain all the content. For HTTP requests, If binary\u000Ais false it will: when in browser return ArrayBuffer and in Node\u000Ait will return Buffer object. When reading from file system\u000Ain both cases it will return Buffer objects.\u000A\u000AThe code that use those function, in binary mode, need to check\u000Aif the result is ArrayBuffer or Node.js/BrowserFS Buffer object." (if (not read-file) (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error "open-input-file: fs not defined")) (let ((*read-file* (promisify fs.readFile))) (set! read-file (lambda (path binary) (let ((buff (*read-file* path))) (if binary (if (eq? self window) (new Blob (vector buff)) buff) (--> buff (toString)))))))))) (if (not fetch-url) (set! fetch-url (lambda (url binary) (if (eq? self window) (let ((res (fetch url))) (if binary (res.arrayBuffer) (res.text))) (http-get url binary))))) (cond ((char=? (string-ref path 0) #\/) (if (not (file-exists? path)) (throw (new Error (string-append "file " path " don't exists"))) (read-file path binary))) ((--> #/^https?:\/\// (test path)) (fetch-url path binary)) (else (%read-file binary (string-append (current-directory) path))))))) (define %read-binary-file (curry %read-file #t)) diff --git a/dist/std.scm b/dist/std.scm index 5a6a2758..1a6d66f4 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1264,7 +1264,11 @@ (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) - (reject e))))))))) + (reject e))))))) + ((not (null? self.BrowserFS)) + (console.warn (string-append "BrowserFS not initilalized " + "IndexedDB is not available")) + nil))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index ea115850..9a9949e2 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1264,7 +1264,11 @@ (lambda (e) (if (null? e) (resolve (BrowserFS.BFSRequire "fs")) - (reject e))))))))) + (reject e))))))) + ((not (null? self.BrowserFS)) + (console.warn (string-append "BrowserFS not initilalized " + "IndexedDB is not available")) + nil))) (Buffer (cond ((eq? self global) self.Buffer) ((not (null? self.BrowserFS)) From 63ac4d67dfe81e769f47c695f7b9a710708fccbb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 16:07:00 +0100 Subject: [PATCH 100/109] better handling of text data from url in Node --- dist/std.min.scm | 2 +- dist/std.scm | 14 +++++++++----- lib/bootstrap.scm | 14 +++++++++----- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/dist/std.min.scm b/dist/std.min.scm index f49e2b8e..e6090e38 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -106,7 +106,7 @@ (define %read-binary-file (curry %read-file #t)) (define %read-text-file (curry %read-file #f)) (define (%fs-promisify-proc fn message) "(%fs-promisify-proc fn string)\u000A\u000AFunction return promisified version of fs function or throw exception\u000Aif fs is not available." (let ((fs (--> lips.env (get (quote **internal-env**)) (get (quote fs))))) (if (null? fs) (throw (new Error (string-append message ": fs not defined"))) (promisify (. fs fn))))) -(define (response->content binary res) "(response->text binary res)\u000A\u000AFunction read all text from Node.js HTTP response object. If binary argument is\u000Atrue it will return Buffer object that can be converted to u8vector.\u000A\u000A***Warrning:*** it may overflow the stack (part of Node) when converting\u000Awhole buffer to u8vector." (let ((result (vector))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" (lambda (chunk) (result.push (Buffer.from chunk "binary")))) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join ""))))))))) +(define (response->content binary res) "(response->text binary res)\u000A\u000AFunction read all text from Node.js HTTP response object. If binary argument\u000Ais true it will return Buffer object that can be converted to u8vector.\u000A\u000A***Warrning:*** it may overflow the stack (part of Node) when converting\u000Awhole buffer to u8vector." (let ((result (vector)) (append (if binary (lambda (chunk) (result.push (Buffer.from chunk "binary"))) (lambda (chunk) (result.push chunk))))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) (res.on "data" append) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) (resolve (result.join ""))))))))) (define response->buffer (curry response->content #t)) (define response->text (curry response->content #f)) (define http-get (if (eq? self window) (lambda (url binary) "(http-get url)\u000A\u000ANode.js Function that send HTTP Request and return string or\u000Abinary Buffer object." (throw (new Error "http-get: function is Node.js only."))) (let* ((http (. (require "http") (quote get))) (https (. (require "https") (quote get)))) (lambda (url binary) "(http-get url)\u000A\u000ANode.js Function that send HTTP Request and return string or\u000Abinary Buffer object." (let ((request (if (null? (url.match #/^https/)) http https))) (new Promise (lambda (resolve reject) (--> (request url (lambda (res) (if (= res.statusCode 200) (resolve (response->content binary res)) (let ((code res.statusCode)) (res.resume) (reject (string-append "Request return " (number->string code))))))) (on "error" reject))))))))) diff --git a/dist/std.scm b/dist/std.scm index 1a6d66f4..df023fd8 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1350,16 +1350,20 @@ (define (response->content binary res) "(response->text binary res) - Function read all text from Node.js HTTP response object. If binary argument is - true it will return Buffer object that can be converted to u8vector. + Function read all text from Node.js HTTP response object. If binary argument + is true it will return Buffer object that can be converted to u8vector. ***Warrning:*** it may overflow the stack (part of Node) when converting whole buffer to u8vector." - (let ((result (vector))) + (let ((result (vector)) + (append (if binary + (lambda (chunk) + (result.push (Buffer.from chunk "binary"))) + (lambda (chunk) + (result.push chunk))))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) - (res.on "data" (lambda (chunk) - (result.push (Buffer.from chunk "binary")))) + (res.on "data" append) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index 9a9949e2..c2229210 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1350,16 +1350,20 @@ (define (response->content binary res) "(response->text binary res) - Function read all text from Node.js HTTP response object. If binary argument is - true it will return Buffer object that can be converted to u8vector. + Function read all text from Node.js HTTP response object. If binary argument + is true it will return Buffer object that can be converted to u8vector. ***Warrning:*** it may overflow the stack (part of Node) when converting whole buffer to u8vector." - (let ((result (vector))) + (let ((result (vector)) + (append (if binary + (lambda (chunk) + (result.push (Buffer.from chunk "binary"))) + (lambda (chunk) + (result.push chunk))))) (res.setEncoding (if binary "binary" "utf8")) (new Promise (lambda (resolve) - (res.on "data" (lambda (chunk) - (result.push (Buffer.from chunk "binary")))) + (res.on "data" append) (res.on "end" (lambda () (if binary (resolve (Buffer.concat result)) From 409761a9c711ad26fefc633cb147eac837c17deb Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 16:19:06 +0100 Subject: [PATCH 101/109] update codemirror regex for new regexes --- lib/js/codemirror.js | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/js/codemirror.js b/lib/js/codemirror.js index b09efae8..fad7b709 100644 --- a/lib/js/codemirror.js +++ b/lib/js/codemirror.js @@ -11,8 +11,7 @@ mod(CodeMirror); })(function(CodeMirror) { "use strict"; - - + CodeMirror.defineMode("lips", function () { var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", ATOM = "atom", NUMBER = "number", BRACKET = "bracket", REGEX = 'string-2'; @@ -46,7 +45,7 @@ CodeMirror.defineMode("lips", function () { var hexMatcher = new RegExp(/^(?:[-+]i|[-+][\da-f]+#*(?:\/[\da-f]+#*)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?@[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?[-+](?:[\da-f]+#*(?:\/[\da-f]+#*)?)?i|[-+]?[\da-f]+#*(?:\/[\da-f]+#*)?)(?=[()\s;"]|$)/i); var decimalMatcher = new RegExp(/^(?:[-+]i|[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)i|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)@[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)|[-+]?(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)[-+](?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*)?i|(?:(?:(?:\d+#+\.?#*|\d+\.\d*#*|\.\d+#*|\d+)(?:[esfdl][-+]?\d+)?)|\d+#*\/\d+#*))(?=[()\s;"]|$)/i); - var re_re = /^\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimuy]*)(?=[()\s;"]|$)/i; + var re_re = /^#\/((?:\\\/|[^/]|\[[^\]]*\/[^\]]*\])+)\/([gimuy]*)(?=[()\s;"]|$)/i; function isBinaryNumber (stream) { return stream.match(binaryMatcher); } @@ -90,10 +89,6 @@ CodeMirror.defineMode("lips", function () { var returnType = null; switch(state.mode){ - case 'regex': - readRegexp(stream); - returnType = REGEX; - break; case "string": // multi-line string parsing mode var next, escaped = false; while ((next = stream.next()) != null) { @@ -189,10 +184,6 @@ CodeMirror.defineMode("lips", function () { returnType = NUMBER; } } - } else if (stream.match(/^\/[^\s]/)) { - console.log({REGEX}); - state.mode = "regex"; - returnType = REGEX; } else if (/^[-+0-9.]/.test(ch) && isDecimalNumber(stream, true)) { // match non-prefixed number, must be decimal returnType = NUMBER; } else if (ch == ";") { // comment From 0f4b4fbf0f85952588e34f3dee8104e3d7bf870c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 22:24:17 +0100 Subject: [PATCH 102/109] fix quoted promises #139 --- README.md | 4 ++-- dist/lips.js | 35 ++++++++++++++++++++++++++--------- dist/lips.min.js | 4 ++-- src/lips.js | 24 +++++++++++++++++++----- tests/core.scm | 7 +++++++ 5 files changed, 56 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7ac38e4b..82cb69c7 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&f4eac9b38a99006c5d215e59aa2a402f8f2cabb4)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&7fcdb640683e8c1d9f2ebaf039e933d2)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&63ac4d67dfe81e769f47c695f7b9a710708fccbb)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&551e169e95ac4e85793d6a5b88285ff2)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 77df7d53..f28d040b 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 16:47:22 +0000 + * build: Thu, 11 Mar 2021 21:22:59 +0000 */ (function () { 'use strict'; @@ -2183,24 +2183,31 @@ function QuotedPromise(promise) { - // prevent exception on unhandled rejecting when using - // '>(Promise.reject (new Error "zonk")) in REPL - promise["catch"](function () {}); + if (is_function(promise["catch"])) { + // prevent exception on unhandled rejecting when using + // '>(Promise.reject (new Error "zonk")) in REPL + promise["catch"](function () {}); + } + this.__promise__ = promise; } // ---------------------------------------------------------------------- QuotedPromise.prototype.then = function (fn) { - return new QuotedPromise(this.__promise__.then(fn)); + return new QuotedPromise(this.valueOf().then(fn)); }; // ---------------------------------------------------------------------- QuotedPromise.prototype["catch"] = function (fn) { - return new QuotedPromise(this.__promise__["catch"](fn)); + return new QuotedPromise(this.valueOf()["catch"](fn)); }; // ---------------------------------------------------------------------- QuotedPromise.prototype.valueOf = function () { + if (!this.__promise__) { + throw new Error('QuotedPromise: invalid promise created'); + } + return this.__promise__; }; // ---------------------------------------------------------------------- @@ -13222,6 +13229,16 @@ }); if (__promise__ === true && is_promise(result)) { + // fix #139 evaluate the code inside the promise that is not data. + // When promise is not quoted it happen automatically, when returing + // promise from evaluate. + result = result.then(function (result) { + if (result instanceof Pair && !value[__data__]) { + return _evaluate(result, eval_args); + } + + return result; + }); return new QuotedPromise(result); } @@ -13717,10 +13734,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Sun, 07 Mar 2021 16:47:22 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 11 Mar 2021 21:22: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('Sun, 07 Mar 2021 16:47:22 +0000').valueOf(); + var date = LString('Thu, 11 Mar 2021 21:22:59 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13760,7 +13777,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Sun, 07 Mar 2021 16:47:22 +0000', + date: 'Thu, 11 Mar 2021 21:22:59 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 5ada83c3..222448ba 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Sun, 07 Mar 2021 16:47:22 +0000 + * build: Thu, 11 Mar 2021 21:22: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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){e["catch"](function(){});this.__promise__=e}QuotedPromise.prototype.then=function(e){return new QuotedPromise(this.__promise__.then(e))};QuotedPromise.prototype["catch"]=function(e){return new QuotedPromise(this.__promise__["catch"](e))};QuotedPromise.prototype.valueOf=function(){return this.__promise__};QuotedPromise.prototype.toString=function(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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)){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("Sun, 07 Mar 2021 16:47:22 +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,") <https://lips.js.org>\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:"Sun, 07 Mar 2021 16:47:22 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){if(is_function(e["catch"])){e["catch"](function(){})}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(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 21:22: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 DEV (".concat(i,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 21:22: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/src/lips.js b/src/lips.js index afd53287..7a72bfec 100644 --- a/src/lips.js +++ b/src/lips.js @@ -805,21 +805,26 @@ // class used to escape promises feature #54 // ---------------------------------------------------------------------- function QuotedPromise(promise) { - // prevent exception on unhandled rejecting when using - // '>(Promise.reject (new Error "zonk")) in REPL - promise.catch(() => {}); + if (is_function(promise.catch)) { + // prevent exception on unhandled rejecting when using + // '>(Promise.reject (new Error "zonk")) in REPL + promise.catch(() => {}); + } this.__promise__ = promise; } // ---------------------------------------------------------------------- QuotedPromise.prototype.then = function(fn) { - return new QuotedPromise(this.__promise__.then(fn)); + return new QuotedPromise(this.valueOf().then(fn)); }; // ---------------------------------------------------------------------- QuotedPromise.prototype.catch = function(fn) { - return new QuotedPromise(this.__promise__.catch(fn)); + return new QuotedPromise(this.valueOf().catch(fn)); }; // ---------------------------------------------------------------------- QuotedPromise.prototype.valueOf = function() { + if (!this.__promise__) { + throw new Error('QuotedPromise: invalid promise created'); + } return this.__promise__; }; // ---------------------------------------------------------------------- @@ -9344,6 +9349,15 @@ // escape promise feature #54 var __promise__ = env.get(Symbol.for('__promise__'), { throwError: false }); if (__promise__ === true && is_promise(result)) { + // fix #139 evaluate the code inside the promise that is not data. + // When promise is not quoted it happen automatically, when returing + // promise from evaluate. + result = result.then(result => { + if (result instanceof Pair && !value[__data__]) { + return evaluate(result, eval_args); + } + return result; + }); return new QuotedPromise(result); } return result; diff --git a/tests/core.scm b/tests/core.scm index 1271009d..8267a859 100644 --- a/tests/core.scm +++ b/tests/core.scm @@ -230,6 +230,13 @@ (await p) (t.is result #(10))))) +(test "core: quoted promise of object with then method" + (lambda (t) + (let ((p '>(object :then (lambda () 10)))) + (--> p (then (lambda (result) + (t.is result 10)))) + (t.is (await p) 10)))) + (test "core: regex" (lambda (t) (let* ((str "#/(\\((?:env|dir|help|apropos)[^)]*\\))/g") From 944ac7c293349b04d3763a27f507eb8d8e8b045c Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 22:41:30 +0100 Subject: [PATCH 103/109] fix unquote-splicing inside direct quasiquoted vector #140 --- CHANGELOG.md | 2 ++ README.md | 4 ++-- dist/lips.js | 10 +++++----- dist/lips.min.js | 4 ++-- src/lips.js | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 693c161f..30cb9119 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,8 @@ * fix `list-ref` according to R7RS errata * fix formatter (pretty print) on multiline strings and atoms * fix repr of vectors (arrays with empty value) +* fix promise quotation of object macro call [#139](https://github.com/jcubic/lips/issues/139) +* fix unquote-splicing inside direct quasiquote vector [#140](https://github.com/jcubic/lips/issues/140) ## 1.0.0-beta.11 ### Breaking diff --git a/README.md b/README.md index 82cb69c7..69035126 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&63ac4d67dfe81e769f47c695f7b9a710708fccbb)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&551e169e95ac4e85793d6a5b88285ff2)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&0f4b4fbf0f85952588e34f3dee8104e3d7bf870c)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&3e55368afee82ab19fc6dffd19f894db)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index f28d040b..4b1f846e 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 21:22:59 +0000 + * build: Thu, 11 Mar 2021 21:38:59 +0000 */ (function () { 'use strict'; @@ -11251,7 +11251,7 @@ function unquoted_arr(arr) { return !!arr.filter(function (value) { - return value instanceof Pair && LSymbol.is(value.car, 'unquote'); + return value instanceof Pair && LSymbol.is(value.car, /^(unquote|unquote-splicing)$/); }).length; } // ----------------------------------------------------------------- @@ -13734,10 +13734,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 11 Mar 2021 21:22:59 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 11 Mar 2021 21:38: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('Thu, 11 Mar 2021 21:22:59 +0000').valueOf(); + var date = LString('Thu, 11 Mar 2021 21:38:59 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13777,7 +13777,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 11 Mar 2021 21:22:59 +0000', + date: 'Thu, 11 Mar 2021 21:38:59 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 222448ba..0c38d879 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 21:22:59 +0000 + * build: Thu, 11 Mar 2021 21:38: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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){if(is_function(e["catch"])){e["catch"](function(){})}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(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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")}).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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 21:22: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 DEV (".concat(i,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 21:22: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 +(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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){if(is_function(e["catch"])){e["catch"](function(){})}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(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 21:38: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 DEV (".concat(i,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 21:38: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/src/lips.js b/src/lips.js index 7a72bfec..795b6568 100644 --- a/src/lips.js +++ b/src/lips.js @@ -7481,7 +7481,7 @@ function unquoted_arr(arr) { return !!arr.filter(value => { return value instanceof Pair && - LSymbol.is(value.car, 'unquote'); + LSymbol.is(value.car, /^(unquote|unquote-splicing)$/); }).length; } // ----------------------------------------------------------------- From 8a1a8b999c35e50887c8c5e0f0e42dc455a5ab7a Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Thu, 11 Mar 2021 23:32:37 +0100 Subject: [PATCH 104/109] add state props and better repr to quotedPromise #138 --- CHANGELOG.md | 1 + README.md | 2 +- dist/lips.js | 210 +++++++++++++++++++++++++++++------------------ dist/lips.min.js | 4 +- src/lips.js | 49 ++++++++++- 5 files changed, 178 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30cb9119..045cb9a5 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ * fix pretty print of different cases of `let` * add binary input/output procedures from R7RS * update vector functions that in R7RS get start and end arguments +* add state props and better repr to quotedPromise ### Bugfix * fix prism highlighting of names (for new context help) * fix error when using help in node REPL and there are no doc string diff --git a/README.md b/README.md index 69035126..2e8b8f01 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&0f4b4fbf0f85952588e34f3dee8104e3d7bf870c)](https://travis-ci.org/jcubic/lips) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&944ac7c293349b04d3763a27f507eb8d8e8b045c)](https://travis-ci.org/jcubic/lips) [![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&3e55368afee82ab19fc6dffd19f894db)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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) diff --git a/dist/lips.js b/dist/lips.js index 4b1f846e..c0a071d9 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 21:38:59 +0000 + * build: Thu, 11 Mar 2021 22:31:09 +0000 */ (function () { 'use strict'; @@ -2183,12 +2183,41 @@ function QuotedPromise(promise) { + var _this = this; + + if (promise instanceof QuotedPromise) { + return promise; + } + + var internal = { + pending: true, + rejected: false, + fulfilled: false, + type: undefined$1 + }; + if (is_function(promise["catch"])) { // prevent exception on unhandled rejecting when using // '>(Promise.reject (new Error "zonk")) in REPL - promise["catch"](function () {}); + promise["catch"](function () { + internal.rejected = true; + internal.pending = false; + }); } + promise.then(function (v) { + internal.type = type(v); + internal.fulfilled = true; + internal.pending = false; + }); + Object.keys(internal).forEach(function (name) { + Object.defineProperty(_this, "__".concat(name, "__"), { + enumerable: true, + get: function get() { + return internal[name]; + } + }); + }); this.__promise__ = promise; } // ---------------------------------------------------------------------- @@ -2213,12 +2242,22 @@ QuotedPromise.prototype.toString = function () { - return '#<promise>'; - }; // ---------------------------------------------------------------------- + if (this.__pending__) { + return QuotedPromise.pending_str; + } + + if (this.__rejected__) { + return QuotedPromise.rejected_str; + } + + return "#<js-promise resolved (".concat(this.__type__, ")>"); + }; + + QuotedPromise.pending_str = '#<js-promise (pending)>'; + QuotedPromise.rejected_str = '#<js-promise (rejected)>'; // ---------------------------------------------------------------------- // :: Parser macros transformers // ---------------------------------------------------------------------- - var specials = { LITERAL: Symbol["for"]('literal'), SPLICE: Symbol["for"]('splice'), @@ -2234,13 +2273,13 @@ }, // events are used in Lexer dynamic rules off: function off(name) { - var _this = this; + var _this2 = this; var fn = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : null; if (Array.isArray(name)) { name.forEach(function (name) { - return _this.off(name, fn); + return _this2.off(name, fn); }); } else if (fn === null) { delete this._events[name]; @@ -2251,11 +2290,11 @@ } }, on: function on(name, fn) { - var _this2 = this; + var _this3 = this; if (Array.isArray(name)) { name.forEach(function (name) { - return _this2.on(name, fn); + return _this3.on(name, fn); }); } else if (!this._events[name]) { this._events[name] = [fn]; @@ -2324,7 +2363,7 @@ var Lexer = /*#__PURE__*/function () { function Lexer(input) { - var _this3 = this; + var _this4 = this; var _ref7 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, _ref7$whitespace = _ref7.whitespace, @@ -2338,7 +2377,7 @@ }); var internals = {}; ['_i', '_whitespace', '_col', '_newline', '_line', '_state', '_next', '_token', '_prev_char'].forEach(function (name) { - Object.defineProperty(_this3, name, { + Object.defineProperty(_this4, name, { configurable: false, enumerable: false, get: function get() { @@ -4725,6 +4764,8 @@ instances.set(cls, fn); }); // ---------------------------------------------------------------------- + var native_types = [LSymbol, LNumber, Macro, Values, InputPort, OutputPort, Environment, QuotedPromise]; // ---------------------------------------------------------------------- + function toString(obj, quote, skip_cycles) { if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { return '#<jQuery(' + obj.length + ')>'; @@ -4751,16 +4792,23 @@ } // standard objects that have toString - var types = [LSymbol, LNumber, Macro, Values, InputPort, Environment]; + var _iterator8 = _createForOfIteratorHelper(native_types), + _step8; - for (var _i4 = 0, _types = types; _i4 < _types.length; _i4++) { - var _type2 = _types[_i4]; + try { + for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { + var _type2 = _step8.value; - if (obj instanceof _type2) { - return obj.toString(quote); - } - } // constants + if (obj instanceof _type2) { + return obj.toString(quote); + } + } // constants + } catch (err) { + _iterator8.e(err); + } finally { + _iterator8.f(); + } if ([nil, eof].includes(obj)) { return obj.toString(); @@ -6885,7 +6933,7 @@ function pipe() { - var _this4 = this; + var _this5 = this; for (var _len7 = arguments.length, fns = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { fns[_key7] = arguments[_key7]; @@ -6900,7 +6948,7 @@ } return fns.reduce(function (args, f) { - return [f.apply(_this4, args)]; + return [f.apply(_this5, args)]; }, args)[0]; }; } // ------------------------------------------------------------------------- @@ -7110,18 +7158,18 @@ }; }; - var _iterator8 = _createForOfIteratorHelper(_keys), - _step8; + var _iterator9 = _createForOfIteratorHelper(_keys), + _step9; try { - for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) { - var key = _step8.value; + for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { + var key = _step9.value; LString.prototype[key] = wrap(String.prototype[key]); } } catch (err) { - _iterator8.e(err); + _iterator9.e(err); } finally { - _iterator8.f(); + _iterator9.f(); } } @@ -8099,10 +8147,10 @@ LComplex.prototype.complex_op = function (name, n, fn) { - var _this5 = this; + var _this6 = this; var calc = function calc(re, im) { - var result = fn(_this5.__re__, re, _this5.__im__, im); + var result = fn(_this6.__re__, re, _this6.__im__, im); if ('im' in result && 're' in result) { if (result.im.cmp(0) === 0 && !LNumber.isFloat(result.im)) { @@ -8774,7 +8822,7 @@ function InputPort(read) { - var _this6 = this; + var _this7 = this; if (typeof this !== 'undefined' && !(this instanceof InputPort) || typeof this === 'undefined') { return new InputPort(read); @@ -8800,22 +8848,22 @@ while (1) { switch (_context9.prev = _context9.next) { case 0: - if (_this6.char_ready()) { + if (_this7.char_ready()) { _context9.next = 5; break; } _context9.next = 3; - return _this6._read(); + return _this7._read(); case 3: line = _context9.sent; parser = new Parser(line, { - env: _this6 + env: _this7 }); case 5: - return _context9.abrupt("return", _this6.__parser__); + return _context9.abrupt("return", _this7.__parser__); case 6: case "end": @@ -8901,14 +8949,14 @@ }; InputPort.prototype.close = function () { - var _this7 = this; + var _this8 = this; this.__parser__ = null; // make content garbage collected, we assign null, // because the value is in prototype this._with_parser = null; ['read', 'close', 'read_char', 'peek-char', 'read_line'].forEach(function (name) { - _this7[name] = function () { + _this8[name] = function () { throw new Error('input-port: port is closed'); }; }); @@ -8958,7 +9006,7 @@ function OutputStringPort(toString) { - var _this8 = this; + var _this9 = this; if (typeof this !== 'undefined' && !(this instanceof OutputStringPort) || typeof this === 'undefined') { return new OutputStringPort(toString); @@ -8975,7 +9023,7 @@ x = x.valueOf(); } - _this8.__buffer__.push(x); + _this9.__buffer__.push(x); }; } @@ -8994,7 +9042,7 @@ function OutputFilePort(filename, fd) { - var _this9 = this; + var _this10 = this; if (typeof this !== 'undefined' && !(this instanceof OutputFilePort) || typeof this === 'undefined') { return new OutputFilePort(filename, fd); @@ -9014,7 +9062,7 @@ x = x.valueOf(); } - _this9.fs().write(_this9._fd, x, function (err) { + _this10.fs().write(_this10._fd, x, function (err) { if (err) { throw err; } @@ -9038,17 +9086,17 @@ }; OutputFilePort.prototype.close = function () { - var _this10 = this; + var _this11 = this; return new Promise(function (resolve, reject) { - _this10.fs().close(_this10._fd, function (err) { + _this11.fs().close(_this11._fd, function (err) { if (err) { reject(err); } else { - read_only(_this10, '_fd', null, { + read_only(_this11, '_fd', null, { hidden: true }); - OutputPort.prototype.close.call(_this10); + OutputPort.prototype.close.call(_this11); resolve(); } }); @@ -9061,7 +9109,7 @@ function InputStringPort(string, env) { - var _this11 = this; + var _this12 = this; if (typeof this !== 'undefined' && !(this instanceof InputStringPort) || typeof this === 'undefined') { return new InputStringPort(string); @@ -9071,13 +9119,13 @@ env = env || global_env; string = string.valueOf(); this._with_parser = this._with_init_parser.bind(this, function () { - if (!_this11.__parser__) { - _this11.__parser__ = new Parser(string, { + if (!_this12.__parser__) { + _this12.__parser__ = new Parser(string, { env: env }); } - return _this11.__parser__; + return _this12.__parser__; }); read_only(this, '__type__', text_port); @@ -9138,11 +9186,11 @@ }; InputByteVectorPort.prototype.close = function () { - var _this12 = this; + var _this13 = this; read_only(this, '__vector__', nil); ['read_u8', 'close', 'peek_u8', 'read_u8_vector'].forEach(function (name) { - _this12[name] = function () { + _this13[name] = function () { throw new Error('Input-binary-port: port is closed'); }; }); @@ -9307,7 +9355,7 @@ var fs, Buffer; this.write = function (x) { - var _this13 = this; + var _this14 = this; typecheck('write', x, ['number', 'uint8array']); var buffer; @@ -9327,7 +9375,7 @@ } return new Promise(function (resolve, reject) { - fs.write(_this13._fd, buffer, function (err) { + fs.write(_this14._fd, buffer, function (err) { if (err) { reject(err); } else { @@ -9589,13 +9637,13 @@ Environment.prototype.clone = function () { - var _this14 = this; + var _this15 = this; // duplicate refs var env = {}; // TODO: duplicated Symbols Object.keys(this.__env__).forEach(function (key) { - env[key] = _this14.__env__[key]; + env[key] = _this15.__env__[key]; }); return new Environment(env, this.__parent__, this.__name__); }; // ------------------------------------------------------------------------- @@ -9752,7 +9800,7 @@ Environment.prototype.constant = function (name, value) { - var _this15 = this; + var _this16 = this; if (this.__env__.hasOwnProperty(name)) { throw new Error("Environment::constant: ".concat(name, " already exists")); @@ -9761,7 +9809,7 @@ if (arguments.length === 1 && is_plain_object(arguments[0])) { var obj = arguments[0]; Object.keys(obj).forEach(function (key) { - _this15.constant(name, obj[key]); + _this16.constant(name, obj[key]); }); } else { Object.defineProperty(this.__env__, name, { @@ -10237,7 +10285,7 @@ }, "(cdr pair)\n\n Function returns cdr (tail) of the list/pair."), // ------------------------------------------------------------------ 'set!': doc(new Macro('set!', function (code) { - var _this16 = this; + var _this17 = this; var _ref29 = arguments.length > 1 && arguments[1] !== undefined$1 ? arguments[1] : {}, dynamic_scope = _ref29.dynamic_scope, @@ -10317,7 +10365,7 @@ var key = parts.pop(); var name = parts.join('.'); - var obj = _this16.get(name, { + var obj = _this17.get(name, { throwError: false }); @@ -10827,7 +10875,7 @@ }, "(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."), // ------------------------------------------------------------------ 'eval': doc('eval', function (code, env) { - var _this17 = this; + var _this18 = this; env = env || this; return _evaluate(code, { @@ -10835,13 +10883,13 @@ //dynamic_scope: this, error: function error(e) { var error = global_env.get('error'); - error.call(_this17, e.message); + error.call(_this18, e.message); if (e.code) { var stack = e.code.map(function (line, i) { return "[".concat(i + 1, "]: ").concat(line); }).join('\n'); - error.call(_this17, stack); + error.call(_this18, stack); } } }); @@ -11905,7 +11953,7 @@ }, "(string->number number [radix])\n\n Function convert string to number."), // ------------------------------------------------------------------ 'try': doc(new Macro('try', function (code, _ref39) { - var _this18 = this; + var _this19 = this; var dynamic_scope = _ref39.dynamic_scope, _error = _ref39.error; @@ -11939,9 +11987,9 @@ } var args = { - env: _this18, + env: _this19, error: function error(e) { - var env = _this18.inherit('try'); + var env = _this19.inherit('try'); if (catch_clause) { env.set(catch_clause.cdr.car.car, e); @@ -11951,7 +11999,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this18; + args.dynamic_scope = _this19; } unpromise(_evaluate(new Pair(new LSymbol('begin'), catch_clause.cdr.cdr), args), function (result) { @@ -11964,7 +12012,7 @@ }; if (dynamic_scope) { - args.dynamic_scope = _this18; + args.dynamic_scope = _this19; } var result = _evaluate(code.car, args); @@ -12024,7 +12072,7 @@ }, "(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."), // ------------------------------------------------------------------ map: doc(function map(fn) { - var _this19 = this; + var _this20 = this; for (var _len30 = arguments.length, lists = new Array(_len30 > 1 ? _len30 - 1 : 0), _key30 = 1; _key30 < _len30; _key30++) { lists[_key30 - 1] = arguments[_key30]; @@ -12035,7 +12083,7 @@ lists.forEach(function (arg, i) { typecheck('map', arg, ['pair', 'nil'], i + 1); // detect cycles - if (arg instanceof Pair && !is_list.call(_this19, arg)) { + if (arg instanceof Pair && !is_list.call(_this20, arg)) { throw new Error("map: argument ".concat(i + 1, " is not a list")); } }); @@ -12057,7 +12105,7 @@ var env = this.newFrame(fn, args); env.set('parent.frame', parent_frame); return unpromise(fn.call.apply(fn, [env].concat(toConsumableArray(args))), function (head) { - return unpromise(map.call.apply(map, [_this19, fn].concat(toConsumableArray(lists.map(function (l) { + return unpromise(map.call.apply(map, [_this20, fn].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))), function (rest) { return new Pair(head, rest); @@ -12153,7 +12201,7 @@ }, "(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."), // ------------------------------------------------------------------ reduce: doc('reduce', fold('reduce', function (reduce, fn, init) { - var _this20 = this; + var _this21 = this; for (var _len33 = arguments.length, lists = new Array(_len33 > 3 ? _len33 - 3 : 0), _key34 = 3; _key34 < _len33; _key34++) { lists[_key34 - 3] = arguments[_key34]; @@ -12173,7 +12221,7 @@ return unpromise(fn.apply(void 0, toConsumableArray(lists.map(function (l) { return l.car; })).concat([init])), function (value) { - return reduce.call.apply(reduce, [_this20, fn, value].concat(toConsumableArray(lists.map(function (l) { + return reduce.call.apply(reduce, [_this21, fn, value].concat(toConsumableArray(lists.map(function (l) { return l.cdr; })))); }); @@ -12818,8 +12866,8 @@ return 'null'; } - for (var _i5 = 0, _Object$entries2 = Object.entries(mapping); _i5 < _Object$entries2.length; _i5++) { - var _Object$entries2$_i = slicedToArray(_Object$entries2[_i5], 2), + for (var _i4 = 0, _Object$entries2 = Object.entries(mapping); _i4 < _Object$entries2.length; _i4++) { + var _Object$entries2$_i = slicedToArray(_Object$entries2[_i4], 2), _key44 = _Object$entries2$_i[0], value = _Object$entries2$_i[1]; @@ -13419,12 +13467,12 @@ }); var stack = new Stack(); - var _iterator9 = _createForOfIteratorHelper(tokens), - _step9; + var _iterator10 = _createForOfIteratorHelper(tokens), + _step10; try { - for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) { - var token = _step9.value; + for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) { + var token = _step10.value; if (open_tokens.includes(token)) { stack.push(token); @@ -13445,9 +13493,9 @@ } } } catch (err) { - _iterator9.e(err); + _iterator10.e(err); } finally { - _iterator9.f(); + _iterator10.f(); } return stack.is_empty(); @@ -13734,10 +13782,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 11 Mar 2021 21:38:59 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 11 Mar 2021 22:31:09 +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('Thu, 11 Mar 2021 21:38:59 +0000').valueOf(); + var date = LString('Thu, 11 Mar 2021 22:31:09 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13777,7 +13825,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 11 Mar 2021 21:38:59 +0000', + date: 'Thu, 11 Mar 2021 22:31:09 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 0c38d879..e6b1da24 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 21:38:59 +0000 + * build: Thu, 11 Mar 2021 22:31:09 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new C(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(P([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function C(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function P(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=P;function k(){return{value:c,done:true}}C.prototype={constructor:C,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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:P(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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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){if(is_function(e["catch"])){e["catch"](function(){})}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(){return"#<promise>"};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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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)});function toString(e,r,t){if(typeof jQuery!=="undefined"&&e instanceof jQuery.fn.init){return"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=[LSymbol,LNumber,Macro,Values,InputPort,Environment];for(var c=0,s=o;c<s.length;c++){var l=s[c];if(e instanceof l){return e.toString(r)}}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}if(e===null){return"null"}if(_typeof_1(e)==="object"){if(is_function(e.toString)&&e.toString[__lambda__]){return e.toString().valueOf()}var f=e.constructor;if(!f){f=Object}var _;if(typeof f.__class__==="string"){_=f.__class__}else{if(is_prototype(e)){return"#<prototype>"}var p=user_repr(e);if(p){if(is_function(p)){return p(e,r)}else{throw new Error("toString: Invalid repr value")}}_=f.name}if(type(e)==="instance"&&!is_native_function(f)){_="instance"}if(is_iterator(e,Symbol.iterator)){if(_){return"#<iterator(".concat(_,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(_){return"#<asyncIterator(".concat(_,")>")}return"#<asyncIterator>"}if(_!==""){return"#<"+_+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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 C(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 P(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;P(" ==> "+e.toString(true));P(r);if(e instanceof LSymbol){var a=e.valueOf();P("[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 C(a)}if(e instanceof Pair){if(e.car instanceof LSymbol&&e.cdr instanceof Pair&&LSymbol.is(e.cdr.car,S)){P("[t 2");var f=e.car.valueOf();var _=r[f];P({expr:e.toString(true),name:f,bindings:r,item:_});if(_===null){return}else if(_){P({b:r[f].toString()});if(_ instanceof Pair){P("[t 2 Pair "+i);P({______:_.toString()});var p=_.car,h=_.cdr;if(i){if(h!==nil){P("|| next 1");n(f,h)}P({car:p.toString()});return p}else{if(p.cdr!==nil){P("|| next 2");n(f,new Pair(p.cdr,h))}P({car:p.car.toString()});return p.car}}else if(_ instanceof Array){P("[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 _}}}P("[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;P("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){P(">> 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))}P(">> 2");var c;if(a.length){P(">> 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{P(">> 3");var p=k(i.car,t,{nested:true});if(p){return new Pair(p,nil)}return nil}}else if(i.car instanceof LSymbol){P(">> 4");if(LSymbol.is(i.cdr.cdr.car,S)){P(">> 4 (a)")}else{P(">> 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)){P({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);P({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}P("<<<< 1");v.append(g)}}P("<<<< 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})}P({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=C(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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator8=_createForOfIteratorHelper(_keys),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var key=_step8.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 21:38: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 DEV (".concat(i,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 21:38: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 +(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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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;if(e instanceof QuotedPromise){return e}var n={pending:true,rejected:false,fulfilled:false,type:undefined$1};if(is_function(e["catch"])){e["catch"](function(){n.rejected=true;n.pending=false})}e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false});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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 22:31:09 +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,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 22:31:09 +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/src/lips.js b/src/lips.js index 795b6568..9bed63a2 100644 --- a/src/lips.js +++ b/src/lips.js @@ -805,11 +805,34 @@ // class used to escape promises feature #54 // ---------------------------------------------------------------------- function QuotedPromise(promise) { + if (promise instanceof QuotedPromise) { + return promise; + } + var internal = { + pending: true, + rejected: false, + fulfilled: false, + type: undefined + }; if (is_function(promise.catch)) { // prevent exception on unhandled rejecting when using // '>(Promise.reject (new Error "zonk")) in REPL - promise.catch(() => {}); + promise.catch(() => { + internal.rejected = true; + internal.pending = false; + }); } + promise.then(v => { + internal.type = type(v); + internal.fulfilled = true; + internal.pending = false; + }); + Object.keys(internal).forEach(name => { + Object.defineProperty(this, `__${name}__`, { + enumerable: true, + get: () => internal[name] + }); + }); this.__promise__ = promise; } // ---------------------------------------------------------------------- @@ -829,8 +852,16 @@ }; // ---------------------------------------------------------------------- QuotedPromise.prototype.toString = function() { - return '#<promise>'; + if (this.__pending__) { + return QuotedPromise.pending_str; + } + if (this.__rejected__) { + return QuotedPromise.rejected_str; + } + return `#<js-promise resolved (${this.__type__})>`; }; + QuotedPromise.pending_str = '#<js-promise (pending)>'; + QuotedPromise.rejected_str = '#<js-promise (rejected)>'; // ---------------------------------------------------------------------- // :: Parser macros transformers // ---------------------------------------------------------------------- @@ -2566,6 +2597,17 @@ instances.set(cls, fn); }); // ---------------------------------------------------------------------- + const native_types = [ + LSymbol, + LNumber, + Macro, + Values, + InputPort, + OutputPort, + Environment, + QuotedPromise + ]; + // ---------------------------------------------------------------------- function toString(obj, quote, skip_cycles, ...pair_args) { if (typeof jQuery !== 'undefined' && obj instanceof jQuery.fn.init) { @@ -2581,8 +2623,7 @@ } } // standard objects that have toString - var types = [LSymbol, LNumber, Macro, Values, InputPort, Environment]; - for (let type of types) { + for (let type of native_types) { if (obj instanceof type) { return obj.toString(quote); } From a91107f52291ffa6a0586f0d8a4bf9b89a6a5325 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Fri, 12 Mar 2021 00:14:31 +0100 Subject: [PATCH 105/109] fix await on rejected promise + add reason #138 --- README.md | 4 ++-- dist/lips.js | 40 +++++++++++++++++++++++----------------- dist/lips.min.js | 4 ++-- src/lips.js | 27 ++++++++++++++++----------- tests/core.scm | 16 ++++++++++++++++ 5 files changed, 59 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 2e8b8f01..5034041a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&944ac7c293349b04d3763a27f507eb8d8e8b045c)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&3e55368afee82ab19fc6dffd19f894db)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&8a1a8b999c35e50887c8c5e0f0e42dc455a5ab7a)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&880858e2a298da59b9ed998656f2f79e)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index c0a071d9..916ba0fe 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 22:31:09 +0000 + * build: Thu, 11 Mar 2021 23:11:48 +0000 */ (function () { 'use strict'; @@ -2185,31 +2185,37 @@ function QuotedPromise(promise) { var _this = this; - if (promise instanceof QuotedPromise) { - return promise; - } - var internal = { pending: true, rejected: false, fulfilled: false, + reason: undefined$1, type: undefined$1 - }; + }; // then added to __promise__ is needed otherwise rejection + // will give UnhandledPromiseRejectionWarning in Node.js + + promise = promise.then(function (v) { + internal.type = type(v); + internal.fulfilled = true; + internal.pending = false; + return v; + }); // promise without catch, used for valueOf - for rejecting + // that should throw an error when used with await + + read_only(this, '_promise', promise, { + hidden: true + }); if (is_function(promise["catch"])) { // prevent exception on unhandled rejecting when using // '>(Promise.reject (new Error "zonk")) in REPL - promise["catch"](function () { + promise = promise["catch"](function (err) { internal.rejected = true; internal.pending = false; + internal.reason = err; }); } - promise.then(function (v) { - internal.type = type(v); - internal.fulfilled = true; - internal.pending = false; - }); Object.keys(internal).forEach(function (name) { Object.defineProperty(_this, "__".concat(name, "__"), { enumerable: true, @@ -2233,11 +2239,11 @@ QuotedPromise.prototype.valueOf = function () { - if (!this.__promise__) { + if (!this._promise) { throw new Error('QuotedPromise: invalid promise created'); } - return this.__promise__; + return this._promise; }; // ---------------------------------------------------------------------- @@ -13782,10 +13788,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 11 Mar 2021 22:31:09 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Thu, 11 Mar 2021 23:11:48 +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('Thu, 11 Mar 2021 22:31:09 +0000').valueOf(); + var date = LString('Thu, 11 Mar 2021 23:11:48 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13825,7 +13831,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 11 Mar 2021 22:31:09 +0000', + date: 'Thu, 11 Mar 2021 23:11:48 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index e6b1da24..236ea085 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 22:31:09 +0000 + * build: Thu, 11 Mar 2021 23:11:48 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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;if(e instanceof QuotedPromise){return e}var n={pending:true,rejected:false,fulfilled:false,type:undefined$1};if(is_function(e["catch"])){e["catch"](function(){n.rejected=true;n.pending=false})}e.then(function(e){n.type=type(e);n.fulfilled=true;n.pending=false});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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 22:31:09 +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,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 22:31:09 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 23:11:48 +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,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 23:11:48 +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/src/lips.js b/src/lips.js index 9bed63a2..1ef898de 100644 --- a/src/lips.js +++ b/src/lips.js @@ -805,28 +805,33 @@ // class used to escape promises feature #54 // ---------------------------------------------------------------------- function QuotedPromise(promise) { - if (promise instanceof QuotedPromise) { - return promise; - } var internal = { pending: true, rejected: false, fulfilled: false, + reason: undefined, type: undefined }; + // then added to __promise__ is needed otherwise rejection + // will give UnhandledPromiseRejectionWarning in Node.js + promise = promise.then(v => { + internal.type = type(v); + internal.fulfilled = true; + internal.pending = false; + return v; + }); + // promise without catch, used for valueOf - for rejecting + // that should throw an error when used with await + read_only(this, '_promise', promise, { hidden: true }); if (is_function(promise.catch)) { // prevent exception on unhandled rejecting when using // '>(Promise.reject (new Error "zonk")) in REPL - promise.catch(() => { + promise = promise.catch((err) => { internal.rejected = true; internal.pending = false; + internal.reason = err; }); } - promise.then(v => { - internal.type = type(v); - internal.fulfilled = true; - internal.pending = false; - }); Object.keys(internal).forEach(name => { Object.defineProperty(this, `__${name}__`, { enumerable: true, @@ -845,10 +850,10 @@ }; // ---------------------------------------------------------------------- QuotedPromise.prototype.valueOf = function() { - if (!this.__promise__) { + if (!this._promise) { throw new Error('QuotedPromise: invalid promise created'); } - return this.__promise__; + return this._promise; }; // ---------------------------------------------------------------------- QuotedPromise.prototype.toString = function() { diff --git a/tests/core.scm b/tests/core.scm index 8267a859..0f4f52a1 100644 --- a/tests/core.scm +++ b/tests/core.scm @@ -237,6 +237,22 @@ (t.is result 10)))) (t.is (await p) 10)))) +(test "core: quoted promise repr" + (lambda (t) + (let ((resolve)) + (define promise '>(new Promise (lambda (r) (set! resolve r)))) + (t.is (repr promise) "#<js-promise (pending)>") + (resolve "xx") + (t.is (await promise) "xx") + (t.is (repr promise) "#<js-promise resolved (string)>")) + (let ((reject)) + (define promise '>(new Promise (lambda (_ r) (set! reject r)))) + (t.is (repr promise) "#<js-promise (pending)>") + (reject (new Error "ZONK")) + (t.is (to.throw (await promise)) true) + (t.is (repr promise) "#<js-promise (rejected)>") + (t.is (not (null? (promise.__reason__.message.match #/ZONK/))) true)))) + (test "core: regex" (lambda (t) (let* ((str "#/(\\((?:env|dir|help|apropos)[^)]*\\))/g") From 3e6ad1b893cf1234508d31d8fbc73cecdf869426 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Sun, 14 Mar 2021 13:24:23 +0100 Subject: [PATCH 106/109] add two quasiquote unit tests --- tests/quotation.scm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/quotation.scm b/tests/quotation.scm index 9ba0e4ef..9ad68bcb 100644 --- a/tests/quotation.scm +++ b/tests/quotation.scm @@ -327,3 +327,14 @@ (lambda (t) (t.is `(foo &(:foo ,(+ 1 2) :bar 10)) (list 'foo &(:foo 3 :bar 10))))) + +(test "quasiquote: should create list from improper list" + (lambda (t) + (t.is (let ((x '(1 2 3))) + `(foo . ,x)) + '(foo 1 2 3)))) + +(test "quasiquote: should create list with unquote-splicing and improper list" + (lambda (t) + (let ((result `((foo ,(- 10 3)) ,@(cdr '(c)) . ,(car '(cons))))) + (t.is result '((foo 7) . cons))))) From d6dc90632c8f3d7b18168a75dad146e8cc5fe1af Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 16 Mar 2021 00:25:21 +0100 Subject: [PATCH 107/109] add SRFI-2 + put SRFIs into file --- dist/std.min.scm | 1 + dist/std.scm | 19 +++++++++++++++ lib/R7RS.scm | 8 ++++--- lib/srfi.scm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 lib/srfi.scm diff --git a/dist/std.min.scm b/dist/std.min.scm index e6090e38..b0198258 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -352,3 +352,4 @@ (define (%export module namespace specs) (quasiquote (begin (unquote-splicing (map (lambda (expr) (cond ((symbol? expr) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote expr)) (unquote expr))))) ((and (pair? expr) (symbol=? (car expr) (quote rename))) (quasiquote (--> (unquote module) (set (quote (unquote namespace)) (quote (unquote (cadr expr))) (unquote (caddr expr)))))))) specs))))) (define-macro (define-library spec . body) "(define-library (library (name namespace) . body)\u000A\u000AMacro for defining modules inside you can use define to create functions.\u000AAnd use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) (define-values (current-directory set-current-directory!) (if (eq? self window) (let ((cwd (string-append location.origin (--> location.pathname (replace #/\/[^/]+$/ "/"))))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's corrent URL." cwd) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (set! cwd value)))) (let ((process (require "process"))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's path from where\u000Athe script was executed." (string-append (process.cwd) "/")) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (process.chdir value)))))) +(define-syntax and-let* (syntax-rules () ((_ ()) #t) ((_ () body ...) (let () body ...)) ((_ ((expression))) expression) ((_ ((symbol expression)) body ...) (let ((symbol expression)) (if symbol (begin body ...)))) ((_ ((symbol expression) expr ...) body ...) (let ((symbol expression)) (and symbol (and-let* (expr ...) body ...)))) ((_ ((expression) expr ...) body ...) (and expression (and-let* (expr ...) body ...)))) "(and-let* ((name expression) expression ...) body)\u000A\u000AMacro that combine let and and. First expression need to be in form of let.\u000ASymbol expression the rest can be boolean expression or name expreession.\u000AThis is implementation of SRFI-2.") diff --git a/dist/std.scm b/dist/std.scm index df023fd8..db52f4c5 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -4188,3 +4188,22 @@ (process.chdir value)))))) ;; ----------------------------------------------------------------------------- +(define-syntax and-let* + (syntax-rules () + ((_ ()) #t) + ((_ () body ...) + (let () body ...)) + ((_ ((expression))) expression) ;; last expression + ((_ ((symbol expression)) body ...) + (let ((symbol expression)) + (if symbol (begin body ...)))) ;; last pair + ((_ ((symbol expression) expr ...) body ...) + (let ((symbol expression)) + (and symbol (and-let* (expr ...) body ...)))) ;; lead pair + ((_ ((expression) expr ...) body ...) + (and expression (and-let* (expr ...) body ...)))) ;; lead expression + "(and-let* ((name expression) expression ...) body) + + Macro that combine let and and. First expression need to be in form of let. + Symbol expression the rest can be boolean expression or name expreession. + This is implementation of SRFI-2.") diff --git a/lib/R7RS.scm b/lib/R7RS.scm index 657e36e9..e28320a9 100755 --- a/lib/R7RS.scm +++ b/lib/R7RS.scm @@ -434,8 +434,8 @@ ;; based on https://srfi.schemers.org/srfi-0/srfi-0.html ;; ----------------------------------------------------------------------------- (define-syntax cond-expand - (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 - srfi-23 srfi-46 srfi-176 lips complex full-unicode + (syntax-rules (and or not else r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 + srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) @@ -468,6 +468,8 @@ (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) + ((cond-expand (srfi-2 body ...) more-clauses ...) + (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) @@ -499,7 +501,7 @@ ;; ----------------------------------------------------------------------------- (define (features) - '(r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips + '(r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower)) ;; ----------------------------------------------------------------------------- diff --git a/lib/srfi.scm b/lib/srfi.scm new file mode 100644 index 00000000..e4227d17 --- /dev/null +++ b/lib/srfi.scm @@ -0,0 +1,61 @@ +;; ----------------------------------------------------------------------------- +;; SRFI-2 https://srfi.schemers.org/srfi-2/srfi-2.html +;; ----------------------------------------------------------------------------- +(define-syntax and-let* + (syntax-rules () + ((_ ()) #t) + ((_ () body ...) + (let () body ...)) + ((_ ((expression))) ;; last/single expression + expression) + ((_ ((symbol expression)) body ...) ;; last/single pair + (let ((symbol expression)) + (if symbol (begin body ...)))) + ((_ ((symbol expression) expr ...) body ...) ;; lead pair + (let ((symbol expression)) + (and symbol (and-let* (expr ...) body ...)))) + ((_ ((expression) expr ...) body ...) ;; lead expression + (and expression (and-let* (expr ...) body ...)))) + "(and-let* ((name expression) expression ...) body) + + Macro that combine let and and. First expression need to be in form of let. + Symbol expression the rest can be boolean expression or name expreession. + This is implementation of SRFI-2.") + +;; ----------------------------------------------------------------------------- +;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html +;; ----------------------------------------------------------------------------- +(set-special! "#," 'sharp-comma) + +(define **reader-ctor-list** '()) + +;; ----------------------------------------------------------------------------- +(define (define-reader-ctor symbol fn) + "(define-reader-ctor symbol fn) + + Define the value for #, syntax. SRFI-10 + Example: + + (define-reader-ctor '+ +) + (print #,(+ 1 2))" + (let ((node (assoc symbol **reader-ctor-list**))) + (if (pair? node) + (set-cdr! node fn) + (set! **reader-ctor-list** (cons (cons symbol fn) + **reader-ctor-list**))))) + +;; ----------------------------------------------------------------------------- +(define-syntax sharp-comma + (syntax-rules () + ((_ (fn arg ...)) + (let ((node (assoc 'fn **reader-ctor-list**))) + (if (pair? node) + ((cdr node) 'arg ...) + (syntax-error (string-append "Invalid symbol " (symbol->string 'fn) + " in expression " (repr '(fn arg ...)))))))) + "(sharp-comma expr) + #,(ctor ...) + + This is syntax extension for SRFI-10. To define the function to be used with + This syntax you need to call `define-reader-ctor` function and define + symbol function mapping.") From a2ecde1c90338410808edb4f6f18383b2f90a393 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 16 Mar 2021 00:26:00 +0100 Subject: [PATCH 108/109] remove let-std macro --- Makefile | 4 +- README.md | 4 +- dist/lips.js | 8 ++-- dist/lips.min.js | 4 +- dist/std.min.scm | 13 +++--- dist/std.scm | 99 +++++++++++++++++++++++++--------------------- lib/bootstrap.scm | 35 ---------------- templates/Makefile | 4 +- 8 files changed, 72 insertions(+), 99 deletions(-) diff --git a/Makefile b/Makefile index 7a5db088..8e2834e1 100644 --- a/Makefile +++ b/Makefile @@ -46,8 +46,8 @@ dist/lips.js: src/lips.js .$(VERSION) rollup.config.js dist/lips.min.js: dist/lips.js .$(VERSION) $(UGLIFY) -o dist/lips.min.js --comments --mangle -- dist/lips.js -dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm - $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm > dist/std.scm +dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm lib/srfi.scm + $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm lib/srfi.scm > dist/std.scm dist/std.min.scm: dist/std.scm $(LIPS) ./scripts/minify.scm dist/std.scm > dist/std.min.scm diff --git a/README.md b/README.md index 5034041a..6a68bc74 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&8a1a8b999c35e50887c8c5e0f0e42dc455a5ab7a)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&880858e2a298da59b9ed998656f2f79e)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![travis](https://travis-ci.org/jcubic/lips.svg?branch=devel&3e6ad1b893cf1234508d31d8fbc73cecdf869426)](https://travis-ci.org/jcubic/lips) +[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&64ed443d0b922f100bd1e27a5b7039bd)](https://coveralls.io/github/jcubic/lips?branch=devel) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 916ba0fe..9285fe09 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 23:11:48 +0000 + * build: Mon, 15 Mar 2021 23:07:00 +0000 */ (function () { 'use strict'; @@ -13788,10 +13788,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Thu, 11 Mar 2021 23:11:48 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Mon, 15 Mar 2021 23:07:00 +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('Thu, 11 Mar 2021 23:11:48 +0000').valueOf(); + var date = LString('Mon, 15 Mar 2021 23:07:00 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13831,7 +13831,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Thu, 11 Mar 2021 23:11:48 +0000', + date: 'Mon, 15 Mar 2021 23:07:00 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 236ea085..4f84adb1 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Thu, 11 Mar 2021 23:11:48 +0000 + * build: Mon, 15 Mar 2021 23:07:00 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Thu, 11 Mar 2021 23:11:48 +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,") <https://lips.js.org>\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:"Thu, 11 Mar 2021 23:11:48 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Mon, 15 Mar 2021 23:07:00 +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,") <https://lips.js.org>\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:"Mon, 15 Mar 2021 23:07:00 +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/dist/std.min.scm b/dist/std.min.scm index b0198258..adfb67c0 100644 --- a/dist/std.min.scm +++ b/dist/std.min.scm @@ -88,12 +88,7 @@ (define-macro (quote-promise expr) "(quote-promise expr)\u000A'>expr\u000A\u000AMacro used to escape promise the whole expression, will be wrapped\u000Awith JavaScript class that behave like Promise but will not\u000Aauto resolve like normal promise." (quasiquote (let ((env)) (set! env (current-environment)) (env.set (Symbol.for "__promise__") #t) (unquote expr)))) (define (await value) (if (instanceof lips.QuotedPromise value) (value.valueOf) value)) (define-macro (let-env-values env spec . body) "(let-env-values env ((name var)) . body)\u000A\u000AMacro add mapping for variables var from specified env,\u000AMacro work similar to let-env but lexical scope is working with it." (let ((env-name (gensym (quote env)))) (quasiquote (let (((unquote env-name) (unquote env))) (let (unquote (map (lambda (pair) (quasiquote ((unquote (car pair)) (--> (unquote env-name) (get (quote (unquote (cadr pair)))))))) spec)) (unquote-splicing body)))))) -(define-macro (let-std spec . body) "(let-std ((name var)) . body)\u000A\u000AMacro that create aliases for variables in global environment.\u000AThis is needed so user don't change constants like stdin or stdout\u000Athat use taken from lexical scope. The function still can use those\u000Afrom interaction-environment." (quasiquote (let-env-values lips.env.__parent__ (unquote spec) (unquote-splicing body)))) (define (apropos name) "(apropos name)\u000A\u000ASearch environment and display names that match the given name.\u000Aname can be regex, string or symbol." (typecheck "apropos" name (quote ("string" "regex" "symbol"))) (let ((regex (lambda (string) (new RegExp (escape-regex string))))) (filter (cond ((string? name) (regex name)) ((symbol? name) (regex (symbol->string name))) (else name)) (env)))) -(set-special! "#," (quote sharp-comma)) -(define **reader-ctor-list** (quote ())) -(define (define-reader-ctor symbol fn) (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**))))) -(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...)))))))))) (define (promisify fn) "(promisify fn)\u000A\u000ASimple function for adding promises to NodeJS callback based function.\u000AFunction tested only with fs module." (lambda args (new Promise (lambda (resolve reject) (apply fn (append args (list (lambda (err data) (if (null? err) (resolve data) (reject err)))))))))) (define-macro (list* . args) "(list* arg1 ...)\u000A\u000AParallel version of list." (let ((result (gensym "result"))) (quasiquote (let (((unquote result) (vector))) (unquote-splicing (map (lambda (arg) (quasiquote (--> (unquote result) (push (quote-promise (unquote arg)))))) args)) (map await (vector->list (unquote result))))))) (define-macro (%not-implemented name) "(not-implemented name)\u000A\u000AReturns new function taht throw exception that function is not implmeneted" (let ((str-name (symbol->string name))) (quasiquote (lambda () (unquote (string-append "(" str-name ")\u000A\u000AThis function is not yet implemented.")) (throw (new Error (unquote (string-append str-name " has not beed implemented")))))))) @@ -296,8 +291,8 @@ (define-syntax define-values (syntax-rules () ((define-values () expr) (define dummy (call-with-values (lambda () expr) (lambda args #f)))) ((define-values (var) expr) (define var expr)) ((define-values (var0 var1 ... varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cadr var0))) (set! var0 (car var0)) v)))) ((define-values (var0 var1 ... . varn) expr) (begin (define var0 (call-with-values (lambda () expr) list)) (define var1 (let ((v (cadr var0))) (set-cdr! var0 (cddr var0)) v)) ... (define varn (let ((v (cdr var0))) (set! var0 (car var0)) v)))) ((define-values var expr) (define var (call-with-values (lambda () expr) list)))) "(define-values (a b ...) expr)\u000A\u000AFunction evaluate expression expr and if it evaluates to result of values\u000Athen it will defined each value as variable like with define.") (define-macro (include . files) "(include file ...)\u000A\u000AMacro that load at least one file content and insert them into one,\u000Abody expression." (if (null? files) (throw (new Error "include: at least one file path required")) (let ((result (vector)) (env (interaction-environment))) (if (eq? self global) (let* ((fs (require "fs")) (readFile (lambda (file) (new Promise (lambda (resolve reject) (fs.readFile file (lambda (err data) (if (null? err) (resolve (--> data (toString))) (reject err))))))))) (for-each (lambda (file) (let* ((expr (lips.parse (readFile file) env))) (set! result (--> result (concat expr))))) files)) (for-each (lambda (file) (let* ((text (--> (fetch file) (text))) (expr (lips.parse text env))) (set! result (--> result (concat expr))))) files)) (if (> result.length 0) (quasiquote (begin (unquote-splicing (vector->list result)))))))) (define-syntax syntax-error (syntax-rules () ((_ "step" arg ...) (join " " (vector->list (vector (repr arg) ...)))) ((_ message arg ...) (raise (new Error (format "~a ~a" message (_ "step" arg ...))))))) -(define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...)))) -(define (features) (quote (r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower))) +(define-syntax cond-expand (syntax-rules (and or not else r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) (begin body ...)) ((cond-expand ((and) body ...) more-clauses ...) (begin body ...)) ((cond-expand ((and req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (cond-expand ((and req2 ...) body ...) more-clauses ...)) more-clauses ...)) ((cond-expand ((or) body ...) more-clauses ...) (cond-expand more-clauses ...)) ((cond-expand ((or req1 req2 ...) body ...) more-clauses ...) (cond-expand (req1 (begin body ...)) (else (cond-expand ((or req2 ...) body ...) more-clauses ...)))) ((cond-expand ((not req) body ...) more-clauses ...) (cond-expand (req (cond-expand more-clauses ...)) (else body ...))) ((cond-expand (r7rs body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-2 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-10 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-22 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-23 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-46 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-176 body ...) more-clauses ...) (begin body ...)) ((cond-expand (lips body ...) more-clauses ...) (begin body ...)) ((cond-expand (complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-unicode body ...) more-clauses ...) (begin body ...)) ((cond-expand (ieee-float body ...) more-clauses ...) (begin body ...)) ((cond-expand (ratios body ...) more-clauses ...) (begin body ...)) ((cond-expand (exact-complex body ...) more-clauses ...) (begin body ...)) ((cond-expand (full-numeric-tower body ...) more-clauses ...) (begin body ...)))) +(define (features) (quote (r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower))) (define *zero-number-chars* #(48 1632 1776 1984 2406 2534 2662 2790 2918 3046 3174 3302 3430 3558 3664 3792 3872 4160 4240 6112 6160 6470 6608 6784 6800 6992 7088 7232 7248 42528 43216 43264 43472 43504 43600 44016 65296 66720 68912 69734 69872 69942 70096 70384 70736 70864 71248 71360 71472 71904 72016 72784 73040 73120 92768 93008 120782 120792 120802 120812 120822 123200 123632 125264 130032)) (define (digit-value chr) "(digit-value chr)\u000A\u000AReturn digit number if character is numeral (as per char-numeric?)\u000Aor #f otherwise." (typecheck "digit-value" chr "character") (if (char-numeric? chr) (let ((ord (char->integer chr))) (do ((i (vector-length *zero-number-chars*) (- i 1)) (found #f) (result #f)) ((or (zero? i) found) result) (let* ((zero (vector-ref *zero-number-chars* (- i 1))) (diff (- ord zero))) (if (and (>= diff 0) (<= diff 9)) (begin (set! result diff) (set! found #t)))))) #f)) (define make-bytevector make-u8vector) @@ -353,3 +348,7 @@ (define-macro (define-library spec . body) "(define-library (library (name namespace) . body)\u000A\u000AMacro for defining modules inside you can use define to create functions.\u000AAnd use export name to add that name to defined environment." (let ((parent (. (current-environment) (quote __parent__))) (module-var (gensym)) (namespace-var (gensym)) (name (car spec)) (namespace (cadr spec))) (quasiquote (let (((unquote module-var) (new-library (unquote (symbol->string name)) (unquote (symbol->string namespace)))) ((unquote namespace-var) (quote (unquote namespace)))) (define-macro (export . body) (%export (unquote module-var) (unquote namespace-var) body)) (unquote-splicing body) (--> (unquote parent) (set (quote (unquote name)) (unquote module-var))))))) (define-values (current-directory set-current-directory!) (if (eq? self window) (let ((cwd (string-append location.origin (--> location.pathname (replace #/\/[^/]+$/ "/"))))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's corrent URL." cwd) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (set! cwd value)))) (let ((process (require "process"))) (values (lambda () "(current-directory)\u000A\u000AReturn corrent working directory, default it's path from where\u000Athe script was executed." (string-append (process.cwd) "/")) (lambda (value) "(set-current-directory! string)\u000A\u000AFunction change current working directory to provided string." (typecheck "set-current-directory!" value "string") (process.chdir value)))))) (define-syntax and-let* (syntax-rules () ((_ ()) #t) ((_ () body ...) (let () body ...)) ((_ ((expression))) expression) ((_ ((symbol expression)) body ...) (let ((symbol expression)) (if symbol (begin body ...)))) ((_ ((symbol expression) expr ...) body ...) (let ((symbol expression)) (and symbol (and-let* (expr ...) body ...)))) ((_ ((expression) expr ...) body ...) (and expression (and-let* (expr ...) body ...)))) "(and-let* ((name expression) expression ...) body)\u000A\u000AMacro that combine let and and. First expression need to be in form of let.\u000ASymbol expression the rest can be boolean expression or name expreession.\u000AThis is implementation of SRFI-2.") +(set-special! "#," (quote sharp-comma)) +(define **reader-ctor-list** (quote ())) +(define (define-reader-ctor symbol fn) "(define-reader-ctor symbol fn)\u000A\u000ADefine the value for #, syntax. SRFI-10\u000AExample:\u000A\u000A(define-reader-ctor '+ +)\u000A(print #,(+ 1 2))" (let ((node (assoc symbol **reader-ctor-list**))) (if (pair? node) (set-cdr! node fn) (set! **reader-ctor-list** (cons (cons symbol fn) **reader-ctor-list**))))) +(define-syntax sharp-comma (syntax-rules () ((_ (fn arg ...)) (let ((node (assoc (quote fn) **reader-ctor-list**))) (if (pair? node) ((cdr node) (quote arg) ...) (syntax-error (string-append "Invalid symbol " (symbol->string (quote fn)) " in expression " (repr (quote (fn arg ...))))))))) "(sharp-comma expr)\u000A#,(ctor ...)\u000A\u000AThis is syntax extension for SRFI-10. To define the function to be used with\u000AThis syntax you need to call `define-reader-ctor` function and define\u000Asymbol function mapping.") diff --git a/dist/std.scm b/dist/std.scm index db52f4c5..dd3c9c13 100644 --- a/dist/std.scm +++ b/dist/std.scm @@ -1109,16 +1109,6 @@ spec) ,@body)))) -;; ----------------------------------------------------------------------------- -(define-macro (let-std spec . body) - "(let-std ((name var)) . body) - - Macro that create aliases for variables in global environment. - This is needed so user don't change constants like stdin or stdout - that use taken from lexical scope. The function still can use those - from interaction-environment." - `(let-env-values lips.env.__parent__ ,spec ,@body)) - ;; ----------------------------------------------------------------------------- (define (apropos name) "(apropos name) @@ -1133,31 +1123,6 @@ (else name)) (env)))) -;; ----------------------------------------------------------------------------- -;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html -;; ----------------------------------------------------------------------------- -(set-special! "#," 'sharp-comma) - -(define **reader-ctor-list** '()) - -;; ----------------------------------------------------------------------------- -(define (define-reader-ctor symbol fn) - (let ((node (assoc symbol **reader-ctor-list**))) - (if (pair? node) - (set-cdr! node fn) - (set! **reader-ctor-list** (cons (cons symbol fn) - **reader-ctor-list**))))) - -;; ----------------------------------------------------------------------------- -(define-syntax sharp-comma - (syntax-rules () - ((_ (fn arg ...)) - (let ((node (assoc 'fn **reader-ctor-list**))) - (if (pair? node) - ((cdr node) 'arg ...) - (syntax-error (string-append "Invalid symbol " (symbol->string 'fn) - " in expression " (repr '(fn arg ...))))))))) - ;; ----------------------------------------------------------------------------- (define (promisify fn) "(promisify fn) @@ -3405,8 +3370,8 @@ ;; based on https://srfi.schemers.org/srfi-0/srfi-0.html ;; ----------------------------------------------------------------------------- (define-syntax cond-expand - (syntax-rules (and or not else r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 - srfi-23 srfi-46 srfi-176 lips complex full-unicode + (syntax-rules (and or not else r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 + srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower) ((cond-expand) (syntax-error "Unfulfilled cond-expand")) ((cond-expand (else body ...)) @@ -3439,6 +3404,8 @@ (begin body ...)) ((cond-expand (srfi-0 body ...) more-clauses ...) (begin body ...)) + ((cond-expand (srfi-2 body ...) more-clauses ...) + (begin body ...)) ((cond-expand (srfi-4 body ...) more-clauses ...) (begin body ...)) ((cond-expand (srfi-6 body ...) more-clauses ...) @@ -3470,7 +3437,7 @@ ;; ----------------------------------------------------------------------------- (define (features) - '(r7rs srfi-0 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips + '(r7rs srfi-0 srfi-2 srfi-4 srfi-6 srfi-10 srfi-22 srfi-23 srfi-46 srfi-176 lips complex full-unicode ieee-float ratios exact-complex full-numeric-tower)) ;; ----------------------------------------------------------------------------- @@ -4187,23 +4154,65 @@ (typecheck "set-current-directory!" value "string") (process.chdir value)))))) +;; ----------------------------------------------------------------------------- +;; ----------------------------------------------------------------------------- +;; SRFI-2 https://srfi.schemers.org/srfi-2/srfi-2.html ;; ----------------------------------------------------------------------------- (define-syntax and-let* (syntax-rules () ((_ ()) #t) ((_ () body ...) (let () body ...)) - ((_ ((expression))) expression) ;; last expression - ((_ ((symbol expression)) body ...) + ((_ ((expression))) ;; last/single expression + expression) + ((_ ((symbol expression)) body ...) ;; last/single pair (let ((symbol expression)) - (if symbol (begin body ...)))) ;; last pair - ((_ ((symbol expression) expr ...) body ...) + (if symbol (begin body ...)))) + ((_ ((symbol expression) expr ...) body ...) ;; lead pair (let ((symbol expression)) - (and symbol (and-let* (expr ...) body ...)))) ;; lead pair - ((_ ((expression) expr ...) body ...) - (and expression (and-let* (expr ...) body ...)))) ;; lead expression + (and symbol (and-let* (expr ...) body ...)))) + ((_ ((expression) expr ...) body ...) ;; lead expression + (and expression (and-let* (expr ...) body ...)))) "(and-let* ((name expression) expression ...) body) Macro that combine let and and. First expression need to be in form of let. Symbol expression the rest can be boolean expression or name expreession. This is implementation of SRFI-2.") + +;; ----------------------------------------------------------------------------- +;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html +;; ----------------------------------------------------------------------------- +(set-special! "#," 'sharp-comma) + +(define **reader-ctor-list** '()) + +;; ----------------------------------------------------------------------------- +(define (define-reader-ctor symbol fn) + "(define-reader-ctor symbol fn) + + Define the value for #, syntax. SRFI-10 + Example: + + (define-reader-ctor '+ +) + (print #,(+ 1 2))" + (let ((node (assoc symbol **reader-ctor-list**))) + (if (pair? node) + (set-cdr! node fn) + (set! **reader-ctor-list** (cons (cons symbol fn) + **reader-ctor-list**))))) + +;; ----------------------------------------------------------------------------- +(define-syntax sharp-comma + (syntax-rules () + ((_ (fn arg ...)) + (let ((node (assoc 'fn **reader-ctor-list**))) + (if (pair? node) + ((cdr node) 'arg ...) + (syntax-error (string-append "Invalid symbol " (symbol->string 'fn) + " in expression " (repr '(fn arg ...)))))))) + "(sharp-comma expr) + #,(ctor ...) + + This is syntax extension for SRFI-10. To define the function to be used with + This syntax you need to call `define-reader-ctor` function and define + symbol function mapping.") diff --git a/lib/bootstrap.scm b/lib/bootstrap.scm index c2229210..389151e8 100755 --- a/lib/bootstrap.scm +++ b/lib/bootstrap.scm @@ -1109,16 +1109,6 @@ spec) ,@body)))) -;; ----------------------------------------------------------------------------- -(define-macro (let-std spec . body) - "(let-std ((name var)) . body) - - Macro that create aliases for variables in global environment. - This is needed so user don't change constants like stdin or stdout - that use taken from lexical scope. The function still can use those - from interaction-environment." - `(let-env-values lips.env.__parent__ ,spec ,@body)) - ;; ----------------------------------------------------------------------------- (define (apropos name) "(apropos name) @@ -1133,31 +1123,6 @@ (else name)) (env)))) -;; ----------------------------------------------------------------------------- -;; SRFI-10 https://srfi.schemers.org/srfi-10/srfi-10.html -;; ----------------------------------------------------------------------------- -(set-special! "#," 'sharp-comma) - -(define **reader-ctor-list** '()) - -;; ----------------------------------------------------------------------------- -(define (define-reader-ctor symbol fn) - (let ((node (assoc symbol **reader-ctor-list**))) - (if (pair? node) - (set-cdr! node fn) - (set! **reader-ctor-list** (cons (cons symbol fn) - **reader-ctor-list**))))) - -;; ----------------------------------------------------------------------------- -(define-syntax sharp-comma - (syntax-rules () - ((_ (fn arg ...)) - (let ((node (assoc 'fn **reader-ctor-list**))) - (if (pair? node) - ((cdr node) 'arg ...) - (syntax-error (string-append "Invalid symbol " (symbol->string 'fn) - " in expression " (repr '(fn arg ...))))))))) - ;; ----------------------------------------------------------------------------- (define (promisify fn) "(promisify fn) diff --git a/templates/Makefile b/templates/Makefile index bfde9baa..ae551e31 100755 --- a/templates/Makefile +++ b/templates/Makefile @@ -46,8 +46,8 @@ dist/lips.js: src/lips.js .$(VERSION) rollup.config.js dist/lips.min.js: dist/lips.js .$(VERSION) $(UGLIFY) -o dist/lips.min.js --comments --mangle -- dist/lips.js -dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm - $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm > dist/std.scm +dist/std.scm: lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm lib/srfi.scm + $(CAT) lib/bootstrap.scm lib/R5RS.scm lib/byte-vectors.scm lib/R7RS.scm lib/srfi.scm > dist/std.scm dist/std.min.scm: dist/std.scm $(LIPS) ./scripts/minify.scm dist/std.scm > dist/std.min.scm From fb5de2dc4e74f8bc7b484759da5477fee3a784c6 Mon Sep 17 00:00:00 2001 From: Jakub Jankiewicz <jcubic@onet.pl> Date: Tue, 16 Mar 2021 13:52:48 +0100 Subject: [PATCH 109/109] fix formatter indent of `let*` --- CHANGELOG.md | 1 + README.md | 4 ++-- dist/lips.js | 12 +++++++----- dist/lips.min.js | 4 ++-- src/lips.js | 3 ++- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 045cb9a5..e7ec7a24 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ * fix complex operation that result in real (e.g. multiplication over conjugation) * fix `list-ref` according to R7RS errata * fix formatter (pretty print) on multiline strings and atoms +* fix formatter indent of `let*` * fix repr of vectors (arrays with empty value) * fix promise quotation of object macro call [#139](https://github.com/jcubic/lips/issues/139) * fix unquote-splicing inside direct quasiquote vector [#140](https://github.com/jcubic/lips/issues/140) diff --git a/README.md b/README.md index 6a68bc74..01077d6d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.11-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&3e6ad1b893cf1234508d31d8fbc73cecdf869426)](https://travis-ci.org/jcubic/lips) -[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&64ed443d0b922f100bd1e27a5b7039bd)](https://coveralls.io/github/jcubic/lips?branch=devel) +[![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) [![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/) diff --git a/dist/lips.js b/dist/lips.js index 9285fe09..c10c1493 100644 --- a/dist/lips.js +++ b/dist/lips.js @@ -31,7 +31,7 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 15 Mar 2021 23:07:00 +0000 + * build: Tue, 16 Mar 2021 12:52:41 +0000 */ (function () { 'use strict'; @@ -1898,6 +1898,8 @@ var special = /([-\\^$[\]()+{}?*.|])/g; return str.replace(special, '\\$1'); } + + return str; } // ---------------------------------------------------------------------- // Stack used in balanced function // TODO: use it in parser @@ -3805,7 +3807,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?: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|\*)?)$/ /* eslint-enable */ ], shift: { @@ -13788,10 +13790,10 @@ var banner = function () { // Rollup tree-shaking is removing the variable if it's normal string because - // obviously 'Mon, 15 Mar 2021 23:07:00 +0000' == '{{' + 'DATE}}'; can be removed + // obviously 'Tue, 16 Mar 2021 12:52:41 +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('Mon, 15 Mar 2021 23:07:00 +0000').valueOf(); + var date = LString('Tue, 16 Mar 2021 12:52:41 +0000').valueOf(); var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date); @@ -13831,7 +13833,7 @@ var lips = { version: 'DEV', banner: banner, - date: 'Mon, 15 Mar 2021 23:07:00 +0000', + date: 'Tue, 16 Mar 2021 12:52:41 +0000', exec: exec, // unwrap async generator into Promise<Array> parse: compose(uniterate_async, parse), diff --git a/dist/lips.min.js b/dist/lips.min.js index 4f84adb1..8c545cf7 100644 --- a/dist/lips.min.js +++ b/dist/lips.min.js @@ -31,6 +31,6 @@ * Copyright (c) 2014-present, Facebook, Inc. * released under MIT license * - * build: Mon, 15 Mar 2021 23:07:00 +0000 + * build: Tue, 16 Mar 2021 12:52:41 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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")}}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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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*|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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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("Mon, 15 Mar 2021 23:07:00 +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,") <https://lips.js.org>\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:"Mon, 15 Mar 2021 23:07:00 +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<r;t++){n[t]=e[t]}return n}var arrayLikeToArray=_arrayLikeToArray;function _unsupportedIterableToArray(e,r){if(!e)return;if(typeof e==="string")return arrayLikeToArray(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(e,r)}var unsupportedIterableToArray=_unsupportedIterableToArray;function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableRest=_nonIterableRest;function _toArray(e){return arrayWithHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableRest()}var toArray=_toArray;function _arrayWithoutHoles(e){if(Array.isArray(e))return arrayLikeToArray(e)}var arrayWithoutHoles=_arrayWithoutHoles;function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nonIterableSpread=_nonIterableSpread;function _toConsumableArray(e){return arrayWithoutHoles(e)||iterableToArray(e)||unsupportedIterableToArray(e)||nonIterableSpread()}var toConsumableArray=_toConsumableArray;var runtime_1=createCommonjsModule(function(e){var r=function(u){var e=Object.prototype;var l=e.hasOwnProperty;var c;var r=typeof Symbol==="function"?Symbol:{};var i=r.iterator||"@@iterator";var t=r.asyncIterator||"@@asyncIterator";var n=r.toStringTag||"@@toStringTag";function a(e,r,t){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true});return e[r]}try{a({},"")}catch(e){a=function(e,r,t){return e[r]=t}}function o(e,r,t,n){var i=r&&r.prototype instanceof s?r:s;var a=Object.create(i.prototype);var u=new P(n||[]);a._invoke=F(e,t,u);return a}u.wrap=o;function f(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}var _="suspendedStart";var p="suspendedYield";var h="executing";var d="completed";var m={};function s(){}function v(){}function y(){}var b={};b[i]=function(){return this};var g=Object.getPrototypeOf;var D=g&&g(g(C([])));if(D&&D!==e&&l.call(D,i)){b=D}var w=y.prototype=s.prototype=Object.create(b);v.prototype=w.constructor=y;y.constructor=v;v.displayName=a(y,n,"GeneratorFunction");function L(e){["next","throw","return"].forEach(function(r){a(e,r,function(e){return this._invoke(r,e)})})}u.isGeneratorFunction=function(e){var r=typeof e==="function"&&e.constructor;return r?r===v||(r.displayName||r.name)==="GeneratorFunction":false};u.mark=function(e){if(Object.setPrototypeOf){Object.setPrototypeOf(e,y)}else{e.__proto__=y;a(e,n,"GeneratorFunction")}e.prototype=Object.create(w);return e};u.awrap=function(e){return{__await:e}};function x(o,c){function s(e,r,t,n){var i=f(o[e],o,r);if(i.type==="throw"){n(i.arg)}else{var a=i.arg;var u=a.value;if(u&&typeof u==="object"&&l.call(u,"__await")){return c.resolve(u.__await).then(function(e){s("next",e,t,n)},function(e){s("throw",e,t,n)})}return c.resolve(u).then(function(e){a.value=e;t(a)},function(e){return s("throw",e,t,n)})}}var r;function e(t,n){function e(){return new c(function(e,r){s(t,n,e,r)})}return r=r?r.then(e,e):e()}this._invoke=e}L(x.prototype);x.prototype[t]=function(){return this};u.AsyncIterator=x;u.async=function(e,r,t,n,i){if(i===void 0)i=Promise;var a=new x(o(e,r,t,n),i);return u.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})};function F(u,o,c){var s=_;return function e(r,t){if(s===h){throw new Error("Generator is already running")}if(s===d){if(r==="throw"){throw t}return k()}c.method=r;c.arg=t;while(true){var n=c.delegate;if(n){var i=A(n,c);if(i){if(i===m)continue;return i}}if(c.method==="next"){c.sent=c._sent=c.arg}else if(c.method==="throw"){if(s===_){s=d;throw c.arg}c.dispatchException(c.arg)}else if(c.method==="return"){c.abrupt("return",c.arg)}s=h;var a=f(u,o,c);if(a.type==="normal"){s=c.done?d:p;if(a.arg===m){continue}return{value:a.arg,done:c.done}}else if(a.type==="throw"){s=d;c.method="throw";c.arg=a.arg}}}}function A(e,r){var t=e.iterator[r.method];if(t===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 m}}r.method="throw";r.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var n=f(t,e.iterator,r.arg);if(n.type==="throw"){r.method="throw";r.arg=n.arg;r.delegate=null;return m}var i=n.arg;if(!i){r.method="throw";r.arg=new TypeError("iterator result is not an object");r.delegate=null;return m}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 m}L(w);a(w,n,"Generator");w[i]=function(){return this};w.toString=function(){return"[object Generator]"};function E(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 S(e){var r=e.completion||{};r.type="normal";delete r.arg;e.completion=r}function P(e){this.tryEntries=[{tryLoc:"root"}];e.forEach(E,this);this.reset(true)}u.keys=function(t){var n=[];for(var e in t){n.push(e)}n.reverse();return function e(){while(n.length){var r=n.pop();if(r in t){e.value=r;e.done=false;return e}}e.done=true;return e}};function C(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 t=-1,n=function e(){while(++t<r.length){if(l.call(r,t)){e.value=r[t];e.done=false;return e}}e.value=c;e.done=true;return e};return n.next=n}}return{next:k}}u.values=C;function k(){return{value:c,done:true}}P.prototype={constructor:P,reset:function(e){this.prev=0;this.next=0;this.sent=this._sent=c;this.done=false;this.delegate=null;this.method="next";this.arg=c;this.tryEntries.forEach(S);if(!e){for(var r in this){if(r.charAt(0)==="t"&&l.call(this,r)&&!isNaN(+r.slice(1))){this[r]=c}}}},stop:function(){this.done=true;var e=this.tryEntries[0];var r=e.completion;if(r.type==="throw"){throw r.arg}return this.rval},dispatchException:function(t){if(this.done){throw t}var n=this;function e(e,r){a.type="throw";a.arg=t;n.next=e;if(r){n.method="next";n.arg=c}return!!r}for(var r=this.tryEntries.length-1;r>=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<i.catchLoc){return e(i.catchLoc,true)}else if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else if(u){if(this.prev<i.catchLoc){return e(i.catchLoc,true)}}else if(o){if(this.prev<i.finallyLoc){return e(i.finallyLoc)}}else{throw new Error("try statement without catch or finally")}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&l.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}if(i&&(e==="break"||e==="continue")&&i.tryLoc<=r&&r<=i.finallyLoc){i=null}var a=i?i.completion:{};a.type=e;a.arg=r;if(i){this.method="next";this.next=i.finallyLoc;return m}return this.complete(a)},complete:function(e,r){if(e.type==="throw"){throw e.arg}if(e.type==="break"||e.type==="continue"){this.next=e.arg}else if(e.type==="return"){this.rval=this.arg=e.arg;this.method="return";this.next="end"}else if(e.type==="normal"&&r){this.next=r}return m},finish:function(e){for(var r=this.tryEntries.length-1;r>=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<r.length;t++){var n=r[t];n.enumerable=n.enumerable||false;n.configurable=true;if("value"in n)n.writable=true;Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){if(r)_defineProperties(e.prototype,r);if(t)_defineProperties(e,t);return e}var createClass=_createClass;function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}var defineProperty=_defineProperty;function _objectWithoutPropertiesLoose(e,r){if(e==null)return{};var t={};var n=Object.keys(e);var i,a;for(a=0;a<n.length;a++){i=n[a];if(r.indexOf(i)>=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<a.length;i++){n=a[i];if(r.indexOf(n)>=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);t<r;t++){n[t]=e[t]}return n}function ownKeys(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);if(e)n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable});t.push.apply(t,n)}return t}function _objectSpread(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};if(e%2){ownKeys(Object(t),true).forEach(function(e){defineProperty(r,e,t[e])})}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(r,Object.getOwnPropertyDescriptors(t))}else{ownKeys(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}}return r}(function(r,t){if(typeof define==="function"&&define.amd){define(["bn.js"],function(e){return r.lips=t(r,e)})}else if((typeof module==="undefined"?"undefined":_typeof_1(module))==="object"&&module.exports){module.exports=t(r,require("bn.js"))}else{r.lips=t(r,r.BN)}})(typeof global!=="undefined"?global:self,function(root,BN,undefined$1){function contentLoaded(t,n){var i=false,e=true,a=t.document,u=a.documentElement,r=a.addEventListener,o=r?"addEventListener":"attachEvent",c=r?"removeEventListener":"detachEvent",s=r?"":"on",l=function e(r){if(r.type=="readystatechange"&&a.readyState!="complete")return;(r.type=="load"?t:a)[c](s+r.type,e,false);if(!i&&(i=true))n.call(t,r.type||r)},f=function r(){try{u.doScroll("left")}catch(e){setTimeout(r,50);return}l("poll")};if(a.readyState=="complete")n.call(t,"lazy");else{if(!r&&u.doScroll){try{e=!t.frameElement}catch(e){}if(e)f()}a[o](s+"DOMContentLoaded",l,false);a[o](s+"readystatechange",l,false);t[o](s+"load",l,false)}}function log(e){var t=arguments.length>1&&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<n){var i=e.charCodeAt(t++);if(i>=55296&&i<=56319&&t<n){var a=e.charCodeAt(t++);if((a&64512)===56320){r.push(((i&1023)<<10)+(a&1023)+65536)}else{r.push(i);t--}}else{r.push(i)}}return r}var character_symbols=Object.keys(characters).join("|");var char_sre_re="#\\\\(?:x[0-9a-f]+|".concat(character_symbols,"|[\\s\\S])");var char_re=new RegExp("^".concat(char_sre_re,"$"),"i");function make_num_stre(i){var e=[["o","[0-7]"],["x","[0-9a-fA-F]"],["b","[01]"],["d","[0-9]"],["","[0-9]"]];var r=e.map(function(e){var r=slicedToArray(e,2),t=r[0],n=r[1];return i(t,n)}).join("|");if(i===gen_complex_re){r=complex_float_stre+"|"+r}return r}function make_type_re(e){return new RegExp("^(?:"+make_num_stre(e)+")$","i")}var complex_re=make_type_re(gen_complex_re);var rational_re=make_type_re(gen_rational_re);var int_re=make_type_re(gen_integer_re);var int_bare_re=new RegExp("^(?:"+gen_integer_re("","[0-9a-f]")+")$","i");var rational_bare_re=new RegExp("^(?:"+gen_rational_re("","[0-9a-f]")+")$","i");var complex_bare_re=new RegExp("^(?:"+gen_complex_re("","[0-9a-f]")+")$","i");var complex_bare_match_re=make_complex_match_re("","[0-9a-fA-F]");var pre_num_parse_re=/((?:#[xodbie]){0,2})(.*)/i;function num_pre_parse(e){var r=e.match(pre_num_parse_re);var t={};if(r[1]){var n=r[1].replace(/#/g,"").toLowerCase().split("");if(n.includes("x")){t.radix=16}else if(n.includes("o")){t.radix=8}else if(n.includes("b")){t.radix=2}else if(n.includes("d")){t.radix=10}if(n.includes("i")){t.inexact=true}if(n.includes("e")){t.exact=true}}t.number=r[2];return t}function parse_rational(e){var r=arguments.length>1&&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(i<Math.abs(t)){n=LNumber([r[1].replace(/\./,""),10]);if(a){t-=a}}}return{exponent:t,mantisa:n}}function parse_float(e){var r=num_pre_parse(e);var t=parseFloat(r.number);var n=(r.number.match(/\.0$/)||!r.number.match(/\./))&&!r.number.match(/e/i);if(!r.inexact){if(r.exact&&n){return LNumber(t)}if(is_int(t)&&r.number.match(/e\+?[0-9]/i)){return LNumber(t)}var i=parse_big_int(r.number),a=i.mantisa,u=i.exponent;if(a!==undefined$1&&u!==undefined$1){var o=LNumber(10).pow(LNumber(Math.abs(u)));if(r.exact&&u<0){return LRational({num:a,denom:o})}else if(u>0){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"#<Thunk>"};function trampoline(n){return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return unwind(n.apply(this,r))}}function unwind(e){while(e instanceof Thunk){var r=e;e=e.fn();if(!(e instanceof Thunk)){r.cont()}}return e}function tokenize(e){var r=arguments.length>1&&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;i<e.length;++i){var a=e[i];if(a==="#;"){if(["(","["].includes(e[i+1])){r=1;t=i}else{n.push([i,i+2])}i+=1;continue}if(t!==null){if([")","]"].includes(a)){r--}else if(["(","["].includes(a)){r++}if(r===0){n.push([t,i+1]);t=null}}}e=e.slice();n.reverse();for(var u=0,o=n;u<o.length;u++){var c=slicedToArray(o[u],2),s=c[0],l=c[1];e.splice(s,l-s)}return e}function isSymbol(e){return _typeof_1(e)==="symbol"||_typeof_1(e)==="object"&&Object.prototype.toString.call(e)==="[object Symbol]"}function LSymbol(e){if(typeof this!=="undefined"&&this.constructor!==LSymbol||typeof this==="undefined"){return new LSymbol(e)}if(e instanceof LString){e=e.valueOf()}if(LSymbol.list[e]instanceof LSymbol){return LSymbol.list[e]}this.__name__=e;if(typeof e==="string"){LSymbol.list[e]=this}}LSymbol.list={};LSymbol.is=function(e,r){return e instanceof LSymbol&&(r instanceof LSymbol&&e.__name__===r.__name__||typeof r==="string"&&e.__name__===r||r instanceof RegExp&&r.test(e.__name__))};LSymbol.prototype.toString=function(e){if(isSymbol(this.__name__)){return symbol_to_string(this.__name__)}var r=this.valueOf();if(e&&r.match(/\s/)){return"|".concat(r,"|")}return r};LSymbol.prototype.toJSON=function(){this.toString(true)};LSymbol.prototype.valueOf=function(){return this.__name__.valueOf()};LSymbol.prototype.is_gensym=function(){return is_gensym(this.__name__)};function symbol_to_string(e){return e.toString().replace(/^Symbol\(([^)]+)\)/,"$1")}function is_gensym(e){if(_typeof_1(e)==="symbol"){return!!e.toString().match(/^Symbol\(#:/)}return false}var gensym=function(){var r=0;return function(){var e=arguments.length>0&&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"#<js-promise resolved (".concat(this.__type__,")>")};QuotedPromise.pending_str="#<js-promise (pending)>";QuotedPromise.rejected_str="#<js-promise (rejected)>";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<t;i++){n[i-1]=arguments[i]}if(this._events[r]){this._events[r].forEach(function(e){return e.apply(void 0,n)})}},remove:function e(r){this.trigger("remove");delete this._specials[r]},append:function e(r,t,n){this.trigger("append");this._specials[r]={seq:r,symbol:t,type:n}},_events:{},_specials:{}};function is_literal(e){return specials.type(e)===specials.LITERAL}var defined_specials=[["'",new LSymbol("quote"),specials.LITERAL],["`",new LSymbol("quasiquote"),specials.LITERAL],[",@",new LSymbol("unquote-splicing"),specials.LITERAL],[",",new LSymbol("unquote"),specials.LITERAL],["'>",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<r;++t){var n=this.__input__[t];if(n==="\n"){var i=this.__input__.substring(this._i,t);this._i=t+1;++this._line;return i}}return this.read_rest()}},{key:"read_rest",value:function e(){var r=this._i;this._i=this.__input__.length;return this.__input__.substring(r)}},{key:"read_string",value:function e(r){var t=this.__input__.length;if(this._i>=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._i<this.__input__.length){++this._i;this._token=null}}},{key:"match_rule",value:function e(r){var t=arguments.length>1&&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;t<n;++t){var i=this.__input__[t];var a=this.__input__[t-1]||"";var u=this.__input__[t+1]||"";if(i==="\n"){++this._line;var o=this._newline;if(this._state===null){this._newline=t+1}if(this._whitespace&&this._state===null){this._next=t+1;this._col=this._i-o;return true}}if(r&&this._state===null&&i.match(/\s/)){if(this._whitespace){if(!u.match(/\s/)){this._next=t+1;this._col=this._i-this._newline;return true}else{continue}}else{this._i=t+1;continue}}r=false;var c=_createForOfIteratorHelper(p.rules),s;try{for(c.s();!(s=c.n()).done;){var l=s.value;if(this.match_rule(l,{prev_char:a,char:i,next_char:u})){var f=l[l.length-1];this._state=f;if(this._state===null){this._next=t+1;this._col=this._i-this._newline;return true}continue e}}}catch(e){c.e(e)}finally{c.f()}if(this._state!==null){continue e}var _=this.__input__.split("\n")[this._line];throw new Error("Invalid Syntax at line ".concat(this._line,"\n").concat(_))}}}]);return p}();Lexer.symbol_rule=function e(r,t){var n=Lexer.literal_rule(r,t,Lexer.boundary,/\S/);return n.concat([[/\S/,/\S/,Lexer.boundary,null,null],[/\S/,/\S/,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]])};Lexer.literal_rule=function e(r,t){var n=arguments.length>2&&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;u<o;++u){var c=[];c.push(r[u]);c.push(r[u-1]||n);c.push(r[u+1]||i);if(u===0){c.push(null);c.push(t)}else if(u===o-1){c.push(t);c.push(null)}else{c.push(t);c.push(t)}a.push(c)}return a};Lexer.string=Symbol["for"]("string");Lexer.symbol=Symbol["for"]("symbol");Lexer.comment=Symbol["for"]("comment");Lexer.regex=Symbol["for"]("regex");Lexer.regex_class=Symbol["for"]("regex_class");Lexer.character=Symbol["for"]("character");Lexer.bracket=Symbol["for"]("bracket");Lexer.b_symbol=Symbol["for"]("b_symbol");Lexer.b_comment=Symbol["for"]("b_comment");Lexer.i_comment=Symbol["for"]("i_comment");Lexer.boundary=/^$|[\s()[\]]/;Lexer._rules=[[/"/,/^$|[^\\]/,null,null,Lexer.string],[/"/,/^$|[^\\]/,null,Lexer.string,null],[/;/,/^$|[^#]/,null,null,Lexer.comment],[/[\s\S]/,null,/\n/,Lexer.comment,null],[/\s/,null,null,Lexer.comment,Lexer.comment],[/#/,null,/\|/,null,Lexer.b_comment],[/\s/,null,null,Lexer.b_comment,Lexer.b_comment],[/#/,/\|/,null,Lexer.b_comment,null],[/#/,null,/;/,null,Lexer.i_comment],[/;/,/#/,null,Lexer.i_comment,null],[/\|/,null,null,null,Lexer.b_symbol],[/\s/,null,null,Lexer.b_symbol,Lexer.b_symbol],[/\|/,null,Lexer.boundary,Lexer.b_symbol,null],[/#/,null,/[bdxoeitf]/i,null,Lexer.symbol],[/#/,null,/\\/,null,Lexer.character],[/\\/,/#/,/\s/,Lexer.character,Lexer.character],[/\\/,/#/,/[()[\]]/,Lexer.character,Lexer.character],[/\s/,/\\/,null,Lexer.character,null],[/\S/,null,Lexer.boundary,Lexer.character,null],[/[()[\]]/,null,null,null,null],[/#/,Lexer.boundary,/\//,null,Lexer.regex],[/[ \t]/,null,null,Lexer.regex,Lexer.regex],[/\[/,null,null,Lexer.regex,Lexer.regex_class],[/\]/,/[^\\]/,null,Lexer.regex_class,Lexer.regex],[/[()[\]]/,null,null,Lexer.regex,Lexer.regex],[/\//,/\\/,null,Lexer.regex,Lexer.regex],[/\//,/[^#]/,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,Lexer.boundary,Lexer.regex,null],[/[gimyus]/,/\//,/[gimyus]/,Lexer.regex,Lexer.regex],[/[gimyus]/,/[gimyus]/,Lexer.boundary,Lexer.regex,null]];Lexer._symbol_rules=[[/\S/,Lexer.boundary,Lexer.boundary,null,null],[/\S/,Lexer.boundary,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,null,null],[/\S/,null,null,null,Lexer.symbol],[/\S/,null,Lexer.boundary,Lexer.symbol,null]];Lexer._cache={valid:false,rules:null};specials.on(["remove","append"],function(){Lexer._cache.valid=false;Lexer._cache.rules=null});Object.defineProperty(Lexer,"rules",{get:function e(){if(Lexer._cache.valid){return Lexer._cache.rules}var r=specials.names().sort(function(e,r){return r.length-e.length||e.localeCompare(r)});Lexer._cache.rules=Lexer._rules.concat(r.reduce(function(e,r){var t=specials.get(r),n=t.type,i=t.symbol;var a;var u;if(r[0]==="#"){if(r.length===1){u=Symbol["for"](r)}else{u=Symbol["for"](r[1])}}else{u=i}if(n===specials.SYMBOL){a=Lexer.symbol_rule(r,u)}else{a=Lexer.literal_rule(r,u)}return e.concat(a)},[]),Lexer._symbol_rules);Lexer._cache.valid=true;return Lexer._cache.rules}});function match_or_null(e,r){return e===null||r.match(e)}var Parser=function(){function o(e){var r=arguments.length>1&&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;o<n.length;++o){if(typeof t[a]==="undefined"){return o}if(t[a]instanceof Pattern){var c;if(["+","*"].includes(t[a].flag)){while(o<n.length){c=e(t[a].patterns,n.slice(o));if(c===-1){break}o+=c}o-=1;a++;continue}else if(t[a].flag==="?"){c=e(t[a].patterns,n.slice(o));if(c===-1){o-=2}else{a++}continue}}else if(t[a]instanceof RegExp){if(!n[o].match(t[a])){return-1}}else if(lips.LString.isString(t[a])){if(t[a].valueOf()!==n[o]){return-1}}else if(_typeof_1(t[a])==="symbol"){if(t[a]===Symbol["for"]("*")){u[a]=u[a]||0;if(["(","["].includes(n[o])){u[a]++}else if([")","]"].includes(n[o])){u[a]--}if(typeof t[a+1]!=="undefined"&&u[a]===0&&i()===-1||u[a]>0){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);n<i.length;n++){var u=slicedToArray(i[n],2),o=u[0],c=u[1];if(r(c)){return+o}}return-1};Formatter.prototype._indent=function e(r,t){var n=this._options(t);var i=lineIndent(r);var a=previousSexp(r);var u=r[r.length-a.length-1];var o=r[r.length-1];if(o.token.match(/^"[\S\s]+[^"]$/)){return i+n.indent}if(a&&a.length){if(a[0].line>0){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].line<a[1].line){return n.offset+a[0].col+1}else if(a.length>3&&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<l.length;++f){var _=l[f];if(_.token.trim()){return _.col}}}}}else{return 0}return i+n.indent};function Ahead(e){this.pattern=e}Ahead.prototype.toString=function(){return"#<pattern(".concat(this.pattern,")>")};Ahead.prototype.match=function(e){return e.match(this.pattern)};function Pattern(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}var n=r.pop();this.patterns=r;this.flag=n}Pattern.prototype.toString=function(){var e=this.patterns.map(function(e){return toString(e)}).join("|");return"#<pattern(".concat(e," ").concat(this.flag,")>")};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;t<e;t++){r[t]=arguments[t]}return new RegExp("^(?:#:)?(?:".concat(r.join("|"),")$"))}Formatter.rules=[[[p_o,keywords_re("begin")],1],[[p_o,let_re,symbol,p_o,let_value,p_e],1],[[p_o,let_re,symbol,sexp,sexp_or_atom],0,not_close],[[p_o,keywords_re("define-syntax"),/.+/],1],[[p_o,non_def,new Pattern([/[^()[\]]/],"+"),sexp],1,not_close],[[p_o,sexp],1,not_close],[[p_o,let_re,sexp],1,not_close],[[p_o,keywords_re("lambda","if"),not_p],1,not_close],[[p_o,keywords_re("while"),not_p,sexp],1,not_close],[[p_o,keywords_re("if"),not_p,glob],1],[[p_o,def_lambda_re,identifiers],1,not_close],[[p_o,def_lambda_re,identifiers,string_re],1,not_close],[[p_o,def_lambda_re,identifiers,string_re,sexp],1,not_close],[[p_o,def_lambda_re,identifiers,sexp],1,not_close]];Formatter.prototype["break"]=function(){var e=this.__code__.replace(/\n[ \t]*/g,"\n ");var r=function e(r){if(r.token.match(string_re)||r.token.match(re_re)){return r.token}else{return r.token.replace(/\s+/," ")}};var t=tokenize(e,true).map(r).filter(function(e){return e!=="\n"});var n=Formatter.rules;for(var i=1;i<t.length;++i){if(!t[i].trim()){continue}var a=t.slice(0,i);var u={};n.map(function(e){return e[1]}).forEach(function(e){e=e.valueOf();if(e>0&&!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;o<n.length;++o){var c=n[o];if(c.token==="\n"){a=this._indent(n.slice(0,o),i);u+=a;if(n[o+1]){n[o+1].token=this._spaces(a);a--;u--;for(var s=o+2;s<n.length;++s){n[s].offset+=u;n[s].col+=a;if(n[s].token==="\n"){o=s-1;break}}}}}return n.map(function(e){if(e.token.match(string_re)){if(e.token.match(/\n/)){var r=new Array(e.col+1).join(" ");var t=e.token.split("\n");e.token=[t[0]].concat(t.slice(1).map(function(e){return r+e})).join("\n")}}return e.token}).join("")};function flatten(e,r){var t=Object.prototype.toString;var n="[object Array]";var i=[];var a=r&&e||e.slice();var u;if(!e.length){return i}u=a.pop();do{if(t.call(u)===n){a.push.apply(a,u)}else{i.push(u)}}while(a.length&&(u=a.pop())!==undefined$1);i.reverse();return i}function Nil(){}Nil.prototype.toString=Nil.prototype.toJSON=function(){return"()"};Nil.prototype.valueOf=function(){console.warn("\nNIL: LIPS just called valueOf on nil constant. "+"This is probably not what you want.");return undefined$1};Nil.prototype.to_object=function(){return{}};Nil.prototype.append=function(e){return new Pair(e,nil)};Nil.prototype.to_array=function(){return[]};var nil=new Nil;function Pair(e,r){if(typeof this!=="undefined"&&this.constructor!==Pair||typeof this==="undefined"){return new Pair(e,r)}this.car=e;this.cdr=r}function to_array(a,u){return function e(r){typecheck(a,r,["pair","nil"]);if(r===nil){return[]}var t=[];var n=r;while(true){if(n instanceof Pair){if(n.haveCycles("cdr")){break}var i=n.car;if(u&&i instanceof Pair){i=this.get(a).call(this,i)}t.push(i);n=n.cdr}else if(n===nil){break}else{throw new Error("".concat(a,": can't convert improper list"))}}return t}}Pair.prototype.flatten=function(){return Pair.fromArray(flatten(this.to_array()))};Pair.prototype.length=function(){var e=0;var r=this;while(true){if(!r||r===nil||!(r instanceof Pair)||r.haveCycles("cdr")){break}e++;r=r.cdr}return e};Pair.match=function(e,r){if(e instanceof LSymbol){return LSymbol.is(e,r)}else if(e instanceof Pair){return Pair.match(e.car,r)||Pair.match(e.cdr,r)}else if(Array.isArray(e)){return e.some(function(e){return Pair.match(e,r)})}else if(is_plain_object(e)){return Object.values(e).some(function(e){return Pair.match(e,r)})}return false};Pair.prototype.find=function(e){return Pair.match(this,e)};Pair.prototype.clone=function(){var t=arguments.length>0&&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,"#<undefined>"]].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"#<procedure(native)>"}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"#<class:".concat(t,">")}return"#<class>"}}if(e.hasOwnProperty("__name__")){var n=e.__name__;if(_typeof_1(n)==="symbol"){n=symbol_to_string(n)}if(typeof n==="string"){return"#<procedure:".concat(n,">")}}if(has_own_function(e,"toString")){return e.toString()}else if(e.name&&!e[__lambda__]){return"#<procedure:".concat(e.name.trim(),">")}else{return"#<procedure>"}}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"#<jQuery("+e.length+")>"}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<i;u++){a[u-3]=arguments[u]}return instances.get(n)(e,{quote:r,skip_cycles:t,pair_args:a})}}var o=_createForOfIteratorHelper(native_types),c;try{for(o.s();!(c=o.n()).done;){var s=c.value;if(e instanceof s){return e.toString(r)}}}catch(e){o.e(e)}finally{o.f()}if([nil,eof].includes(e)){return e.toString()}if(is_function(e)){return function_to_string(e)}if(e===root){return"#<js:global>"}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"#<prototype>"}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"#<iterator(".concat(f,")>")}return"#<iterator>"}if(is_iterator(e,Symbol.asyncIterator)){if(f){return"#<asyncIterator(".concat(f,")>")}return"#<asyncIterator>"}if(f!==""){return"#<"+f+">"}return"#<Object>"}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"#<macro:".concat(this.__name__,">")};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<recur_guard)){r.next=14;break}return r.abrupt("return",s);case 14:if(n!==-1){n=n-1}return r.abrupt("return",d(s,n,l));case 16:o=s;case 17:if(!(o instanceof LSymbol)){r.next=19;break}return r.abrupt("return",quote(o));case 19:if(!(o instanceof Pair)){r.next=24;break}if(!(n!==-1&&n<=1||n<recur_guard)){r.next=22;break}return r.abrupt("return",o);case 22:if(n!==-1){n=n-1}return r.abrupt("return",d(o,n,i));case 24:if(!is_atom(o)){r.next=26;break}return r.abrupt("return",o);case 26:f=t.car;if(!(f instanceof Pair)){r.next=31;break}r.next=30;return d(f,n,i);case 30:f=r.sent;case 31:_=t.cdr;if(!(_ instanceof Pair)){r.next=36;break}r.next=35;return d(_,n,i);case 35:_=r.sent;case 36:p=new Pair(f,_);return r.abrupt("return",p);case 38:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)};d=function e(r,t,n){return i.apply(this,arguments)};n=h["env"]=this;if(!(t.cdr instanceof Pair&&LNumber.isNumber(t.cdr.car))){r.next=9;break}r.t0=quote;r.next=7;return d(t,t.cdr.car.valueOf(),n);case 7:r.t1=r.sent.car;return r.abrupt("return",(0,r.t0)(r.t1));case 9:if(!a){r.next=15;break}r.t2=quote;r.next=13;return d(t,1,n);case 13:r.t3=r.sent.car;return r.abrupt("return",(0,r.t2)(r.t3));case 15:r.t4=quote;r.next=18;return d(t,-1,n);case 18:r.t5=r.sent.car;return r.abrupt("return",(0,r.t4)(r.t5));case 20:case"end":return r.stop()}}},e,this)}));return function(e,r){return t.apply(this,arguments)}}()}function Syntax(e,r){this.__env__=r;this.__fn__=e;this.__defmacro__=true}Syntax.__merge_env__=Symbol["for"]("merge");Syntax.prototype=Object.create(Macro.prototype);Syntax.prototype.invoke=function(e,r,t){var n=r.error,i=r.env;var a={error:n,env:i,dynamic_scope:this.__env__,macro_expand:t};return this.__fn__.call(i,e,a,this.__name__||"syntax")};Syntax.prototype.constructor=Syntax;Syntax.prototype.toString=function(){if(this.__name__){return"#<syntax:".concat(this.__name__,">")}return"#<syntax>"};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;r<t;++r){s.set(l[r].name,e[r])}}).then(p)}else{l.forEach(function(e){var r=e.name,t=e.value;s.set(r,t)})}}return p()}else{if(h==="let"){f=c}else if(h==="letrec"){f=s}var i=_evaluate(t.cdr.car,{env:f,dynamic_scope:a,error:u});if(h==="let*"){f=s=f.inherit("let*["+_+"]")}if(l){l.push({name:t.car,value:i});return r()}else{return unpromise(i,function(e){s.set(t.car,e);return r()})}}}()})}function pararel(e,c){return new Macro(e,function(e){var r=arguments.length>1&&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;n<r;n++){t[n-1]=arguments[n]}t.forEach(function(e){typecheck("",e,"number")});return e.apply(void 0,t)}function pipe(){var n=this;for(var e=arguments.length,i=new Array(e),r=0;r<e;r++){i[r]=arguments[r]}i.forEach(function(e,r){typecheck("pipe",e,"function",r+1)});return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}return i.reduce(function(e,r){return[r.apply(n,e)]},r)[0]}}function compose(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}r.forEach(function(e,r){typecheck("compose",e,"function",r+1)});return pipe.apply(void 0,toConsumableArray(r.reverse()))}function fold(u,o){var c=this;return function e(r,t){typecheck(u,r,"function");for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++){i[a-2]=arguments[a]}if(i.some(is_null)){if(typeof t==="number"){return LNumber(t)}return t}else{return o.call.apply(o,[c,e,r,t].concat(i))}}}function limitMathOp(e,r){return limit(e+1,curry(guardMathCall,r))}var singleMathOp=curry(limitMathOp,1);var binaryMathOp=curry(limitMathOp,2);function reduceMathOp(n){var i=arguments.length>1&&arguments[1]!==undefined$1?arguments[1]:null;return function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(i!==null){r=[i].concat(toConsumableArray(r))}return r.reduce(binaryMathOp(n))}}function curry(a){for(var e=arguments.length,r=new Array(e>1?e-1:0),t=1;t<e;t++){r[t-1]=arguments[t]}typecheck("curry",a,"function");var u=a.length;return function(){var n=r.slice();function i(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}n=n.concat(r);if(n.length>=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;t<e;t++){r[t]=arguments[t]}return i.apply(void 0,toConsumableArray(r.slice(0,n)))}}function LCharacter(e){if(typeof this!=="undefined"&&!(this instanceof LCharacter)||typeof this==="undefined"){return new LCharacter(e)}if(e instanceof LString){e=e.valueOf()}var r;if(Array.from(e).length>1){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;t<e;t++){r[t]=arguments[t]}return n.apply(this.__string__,r)}};var _iterator9=_createForOfIteratorHelper(_keys),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var key=_step9.value;LString.prototype[key]=wrap(String.prototype[key])}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}}LString.isString=function(e){return e instanceof LString||typeof e==="string"};LString.prototype.get=function(e){return Array.from(this.__string__)[e]};LString.prototype.cmp=function(e){typecheck("LStrign::cmp",e,"string");var r=this.valueOf();var t=e.valueOf();if(r<t){return-1}else if(r===t){return 0}else{return 1}};LString.prototype.lower=function(){return LString(this.__string__.toLowerCase())};LString.prototype.upper=function(){return LString(this.__string__.toUpperCase())};LString.prototype.set=function(e,r){if(r instanceof LCharacter){r=r.__char__}var t=[];if(e>0){t.push(this.__string__.substring(0,e))}t.push(r);if(e<this.__string__.length-1){t.push(this.__string__.substring(e+1))}this.__string__=t.join("")};Object.defineProperty(LString.prototype,"length",{get:function e(){return this.__string__.length}});LString.prototype.clone=function(){return LString(this.valueOf())};LString.prototype.fill=function(e){if(e instanceof LCharacter){e=e.toString()}var r=this.__string__.length;this.__string__=new Array(r+1).join(e)};function LNumber(e){var r=arguments.length>1&&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<<t}};LNumber.prototype.op=function(e,r){if(typeof r==="undefined"){return LNumber(LNumber._ops[e](this.valueOf()))}if(typeof r==="number"){r=LNumber(r)}if(Number.isNaN(this.__value__)&&!LNumber.isComplex(r)||!LNumber.isComplex(this)&&Number.isNaN(r.__value__)){return LNumber(NaN)}var t=this.coerce(r),n=slicedToArray(t,2),i=n[0],a=n[1];if(i._op){return i._op(e,a)}return LNumber(LNumber._ops[e](i,a))};LNumber.prototype.sqrt=function(){var e=this.valueOf();if(this.cmp(0)<0){return LComplex({re:0,im:Math.sqrt(-e)})}return new LNumber(Math.sqrt(e))};var pow=function e(r,t){var n=typeof r==="bigint"?BigInt(1):1;return new Array(Number(t)).fill(0).reduce(function(e){return e*r},n)};LNumber.prototype.pow=function(e){var r;if(LNumber.isBN(this.__value__)){r=this.__value__.pow(e.__value__)}else{r=pow(this.__value__,e.__value__)}return LNumber(r)};LNumber.prototype.abs=function(){var e=this.__value__;if(LNumber.isNative(this.__value__)){if(e<0){e=-e}}else if(LNumber.isBN(e)){e.iabs()}return new LNumber(e)};LNumber.prototype.isOdd=function(){if(LNumber.isNative(this.__value__)){if(this.isBigNumber()){return this.__value__%BigInt(2)===BigInt(1)}return this.__value__%2===1}else if(LNumber.isBN(this.__value__)){return this.__value__.isOdd()}};LNumber.prototype.isEven=function(){return!this.isOdd()};LNumber.prototype.cmp=function(e){var r=this.coerce(e),t=slicedToArray(r,2),n=t[0],i=t[1];function a(e,r){if(e.__value__<r.__value__){return-1}else if(e.__value__===r.__value__){return 0}else{return 1}}if(n.__type__==="bigint"){if(LNumber.isNative(n.__value__)){return a(n,i)}else if(LNumber.isBN(n.__value__)){return this.__value__.cmp(i.__value__)}}else if(n instanceof LFloat){return a(n,i)}};function LComplex(e){var r=arguments.length>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 t<n?r:e(t,r%t)};return i(Math.abs(r),Math.abs(t))},t=r(n?n:1/1e4,1,e);return LRational({num:Math.floor(e/t),denom:Math.floor(1/t)})}}function rationalize(e,r){var t=e.sub(r);var n=e.add(r);var i;if(t.cmp(n)>0){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<n;a++){i[a]=u[a]}return r.abrupt("return",c.apply(void 0,[t].concat(i)));case 5:case"end":return r.stop()}}},e)}));return function(){return e.apply(this,arguments)}}()};InputPort.prototype.is_open=function(){return this._with_parser!==null};InputPort.prototype.close=function(){var r=this;this.__parser__=null;this._with_parser=null;["read","close","read_char","peek-char","read_line"].forEach(function(e){r[e]=function(){throw new Error("input-port: port is closed")}});this.char_ready=function(){return false}};InputPort.prototype.toString=function(){return"#<input-port>"};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"#<output-port>"};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"#<output-port (string)>"};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"#<output-port ".concat(this.__filename__,">")};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"#<input-port (string)>"};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"#<input-port (bytevector)>"};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"#<output-port (bytevector)>"};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"#<input-port (".concat(this.__filename__,")>")};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"#<input-binary-port (".concat(this.__filename__,")>")};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"#<eof>"};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:"+this.__name__+">"};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;i<t;i++){n[i-1]=arguments[i]}if(is_function(r)&&_typeof_1(n[0])!=="symbol"){r=unbind(r)}var a;var u=n.length;while(n.length){var o=n.shift();var c=unbox(o);if(c==="__code__"&&is_function(r)&&typeof r.__code__==="undefined"){a=native_lambda}else{a=r[c]}if(typeof a==="undefined"){if(n.length){throw new Error("Try to get ".concat(n[0]," from undefined"))}return a}else{var s;if(n.length-1<u){s=r}a=patch_value(a,s)}r=a}return a},"(. obj . args)\n (get obj . args)\n\n Function use object as base and keep using arguments to get the\n property of JavaScript object. Arguments need to be a strings.\n e.g. `(. console \"log\")` if you use any function inside LIPS is\n will be weakly bind (can be rebind), so you can call this log function\n without problem unlike in JavaScript when you use\n `var log = console.log`.\n `get` is an alias because . don't work in every place, e.g. you can't\n pass it as argument.");function internal(e,r){var t=interaction(e,"**internal-env**");return t.get(r)}function interaction(e,r){var t=e.get("**interaction-environment**");return t.get(r)}var internal_env=new Environment({stdout:new OutputPort(function(){var e;(e=console).log.apply(e,arguments)}),stderr:new OutputPort(function(){var e;(e=console).error.apply(e,arguments)}),stdin:InputPort(function(){return Promise.resolve(prompt(""))}),"letter-unicode-regex":/(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/,"numeral-unicode-regex":/(?:[0-9\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])/,"space-unicode-regex":/[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/},undefined$1,"internal");var global_env=new Environment({nil:nil,eof:eof,undefined:undefined$1,true:true,false:false,null:null,NaN:LNumber(NaN),"peek-char":doc("peek-char",function(){var e=arguments.length>0&&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;a<n;a++){i[a]=arguments[a]}i.forEach(function(e){r.call(global_env,e);t.call(global_env)})},"(print . args)\n\n Function convert each argument to string and print the result to\n standard output (by default it's console but it can be defined\n it user code), the function call newline after printing each arg."),format:doc(function e(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++){n[i-1]=arguments[i]}typecheck("format",r,"string");var a=/(~[as%~])/g;var u=r.match(/(~[as])/g);if(u&&u.length>n.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;a<n;a++){i[a]=arguments[a]}var u=i.map(t).join(" ");r.write.call(global_env,u);global_env.get("newline")(r)},"(error . args)\n\n Display error message."),"%same-functions":doc("%same-functions",function(e,r){if(!is_function(e)){return false}if(!is_function(r)){return false}return unbind(e)===unbind(r)},"(%same-functions a b)\n\n Helper function that check if two bound functions are the same"),help:doc(new Macro("help",function(e,r){var t=r.dynamic_scope,n=r.error;var i;if(e.car instanceof LSymbol){i=e.car}else if(e.car instanceof Pair&&e.car.car instanceof LSymbol){i=e.car.car}else{var a=this;if(t){t=this}var u=_evaluate(e.car,{env:a,error:n,dynamic_scope:t});if(u&&u.__doc__){return u.__doc__}return}var o;var c=this.get(i);o=c&&c.__doc__;if(o){return o}var s=this.ref(i);if(s){o=s.doc(i);if(o){return o}}}),"(help object)\n\n Macro returns documentation for function or macro. You can save the function\n or macro in variable and use it in context. But help for variable require\n to pass the symbol itself."),cons:doc(function e(r,t){return new Pair(r,t)},"(cons left right)\n\n Function return new Pair out of two arguments."),car:doc(function e(r){typecheck("car",r,"pair");return r.car},"(car pair)\n\n Function returns car (head) of the list/pair."),cdr:doc(function e(r){typecheck("cdr",r,"pair");return r.cdr},"(cdr pair)\n\n Function returns cdr (tail) of the list/pair."),"set!":doc(new Macro("set!",function(e){var a=this;var r=arguments.length>1&&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 ((<var> <init> <next>)) (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;n<r;n++){t[n]=arguments[n]}return Values(t)},"(values a1 a2 ...)\n\n If called with more then one elment it will create special\n Values object that can be used in call-with-values function"),"call-with-values":doc("call-with-values",function(e,r){typecheck("call-with-values",e,"function",1);typecheck("call-with-values",r,"function",2);var t=e();if(t instanceof Values){return r.apply(void 0,toConsumableArray(t.valueOf()))}return r(t)},"(call-with-values producer consumer)\n\n Calls its producer argument with no values and a continuation that,\n when passed some values, calls the consumer procedure with those\n values as arguments."),"current-environment":doc("current-environment",function(){if(this.__name__==="__frame__"){return this.__parent__}return this},"(current-environment)\n\n Function return current environement."),"parent.frame":doc("parent.frame",function(){return user_env},"(parent.frame)\n\n Return parent environment if called from inside function.\n If no parent frame found it return nil."),eval:doc("eval",function(e,r){var n=this;r=r||this;return _evaluate(e,{env:r,error:function e(r){var e=global_env.get("error");e.call(n,r.message);if(r.code){var t=r.code.map(function(e,r){return"[".concat(r+1,"]: ").concat(e)}).join("\n");e.call(n,t)}}})},"(eval expr)\n (eval expr environment)\n\n Function evalute LIPS Scheme code."),lambda:new Macro("lambda",function(f){var e=arguments.length>1&&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;u<i;u++){a[u]=arguments[u]}if(this instanceof Environment){var o={throwError:false};e.set("arguments",this.get("arguments",o));e.set("parent.frame",this.get("parent.frame",o))}else{var c=a.slice();c.callee=m;c.env=e;e.set("arguments",c)}if(r instanceof LSymbol||r!==nil){while(true){if(r.car!==nil){if(r instanceof LSymbol){n=quote(Pair.fromArray(a.slice(t),false));e.__env__[r.__name__]=n;break}else{n=a[t];e.__env__[r.car.__name__]=n}}if(r.cdr===nil){break}t++;r=r.cdr}}if(_){_=e}var s=d?f.cdr.cdr:f.cdr;var l=new Pair(new LSymbol("begin"),s);return _evaluate(l,{env:e,dynamic_scope:_,error:p})}var r=f.car instanceof Pair?f.car.length():null;m.__code__=new Pair(new LSymbol("lambda"),f);m[__lambda__]=true;if(!(f.car instanceof Pair)){return doc(m,d,true)}return doc(setFnLength(m,r),d,true)},"(lambda (a b) body)\n (lambda args body)\n (lambda (a b . rest) body)\n\n Macro lambda create new anonymous function, if first element of the body\n is string and there is more elements it will be documentation, that can\n be read using (help fn)"),macroexpand:new Macro("macroexpand",macro_expand()),"macroexpand-1":new Macro("macroexpand-1",macro_expand(true)),"define-macro":doc(new Macro(macro,function(o,e){var c=e.dynamic_scope,s=e.error;if(o.car instanceof Pair&&o.car.car instanceof LSymbol){var r=o.car.car.__name__;var l;if(LString.isString(o.cdr.car)&&o.cdr.cdr instanceof Pair){l=o.cdr.car.valueOf()}var t=Macro.defmacro(r,function(e){var r=new Environment({},this,"defmacro");var t=o.car.cdr;var n=e;while(true){if(t===nil){break}if(t instanceof LSymbol){r.__env__[t.__name__]=n;break}else if(t.car!==nil){if(n===nil){r.__env__[t.car.__name__]=nil}else{if(n.car instanceof Pair){n.car[__data__]=true}r.__env__[t.car.__name__]=n.car}}if(t.cdr===nil){break}if(n!==nil){n=n.cdr}t=t.cdr}if(c){c=r}var i={env:r,dynamic_scope:c,error:s};if(o.cdr instanceof Pair){var a=l?o.cdr.cdr:o.cdr;var u=a.reduce(function(e,r){return _evaluate(r,i)});return unpromise(u,function(e){if(_typeof_1(e)==="object"){delete e[__data__]}return e})}},l,true);t.__code__=new Pair(new LSymbol("define-macro"),o);this.set(r,t)}}),"(define-macro (name . args) body)\n\n Meta macro, macro that create new macros, if return value is list structure\n it will be evaluated when macro is invoked. You can use quasiquote ` and\n unquote , and unquote-splicing ,@ inside to create expression that will be\n evaluated on runtime. Macros works like this: if you pass any expression to\n macro the arguments will not be evaluated unless macro itself evaluate it.\n Because of this macro can manipulate expression (arguments) as lists."),"syntax-rules":new Macro("syntax-rules",function(v,e){var y=e.dynamic_scope,b=e.error;var g=this;function D(e){var r=[];while(e!==nil){var t=e.car;r.push(t.valueOf());e=e.cdr}return r}function r(e){while(e!==nil){var r=e.car;if(!(r instanceof LSymbol)){throw new Error("syntax-rules: wrong identifier")}e=e.cdr}}if(v.car instanceof LSymbol){r(v.cdr.car)}else{r(v.car)}var t=new Syntax(function(e,r){var t=r.macro_expand;var n=g.inherit("syntax");if(y){y=n}var i=this;if(i.__name__===Syntax.__merge_env__){var a=Object.getOwnPropertySymbols(i.__env__);a.forEach(function(e){i.__parent__.set(e,i.__env__[e])});i=i.__parent__}var u={env:n,dynamic_scope:y,error:b};var o,c,s;if(v.car instanceof LSymbol){o=v.car;s=D(v.cdr.car);c=v.cdr.cdr}else{o="...";s=D(v.car);c=v.cdr}while(c!==nil){var l=c.car.car;var f=c.car.cdr.car;log(l);var _=extract_patterns(l,e,s,o,{expansion:this,define:g});if(_){if(is_debug()){console.log(JSON.stringify(symbolize(_),true,2));console.log("PATTERN: "+l.toString(true));console.log("MACRO: "+e.toString(true))}var p=[];var h=transform_syntax({bindings:_,expr:f,symbols:s,scope:n,lex_scope:i,names:p,ellipsis:o});if(h){f=h}var d=i.merge(n,Syntax.__merge_env__);if(t){return{expr:f,scope:d}}var m=_evaluate(f,_objectSpread(_objectSpread({},u),{},{env:d}));return clear_gensyms(m,p)}c=c.cdr}throw new Error("Invalid Syntax ".concat(e.toString(true)))},g);t.__code__=v;return t},"(syntax-rules () (pattern expression) ...)\n\n Base of Hygienic macro, it will return new syntax expander\n that works like lisp macros."),quote:doc(new Macro("quote",function(e){return quote(e.car)}),"(quote expression)\n\n Macro that return single lips expression as data (it don't evaluate its\n argument). It will return list of pairs if put in front of lips code.\n And if put in fron of symbol it will return that symbol not value\n associated with that name."),"unquote-splicing":doc("unquote-splicing",function(){throw new Error("You can't call `unquote-splicing` outside of quasiquote")},"(unquote-splicing code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters ,@ and create call to this pseudo function. It can be used\n to evalute expression inside and return the value without parenthesis.\n the value will be joined to the output list structure."),unquote:doc("unquote",function(){throw new Error("You can't call `unquote` outside of quasiquote")},"(unquote code)\n\n Special form to be used in quasiquote macro, parser is processing special\n characters , and create call to this pseudo function. It can be used\n to evalute expression inside and return the value, the output is inserted\n into list structure created by queasiquote."),quasiquote:Macro.defmacro("quasiquote",function(e,r){var o=r.dynamic_scope,c=r.error;var s=this;if(o){o=s}function a(e){return e instanceof Pair||is_plain_object(e)||Array.isArray(e)}function l(e,r){var t=arguments.length>2&&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+1<i){t=d(r.cdr,n+1,i)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}if(!(t instanceof Pair)){throw new Error("Expecting list ".concat(type(r)," found"))}return e.concat(t.to_array())}e.push(d(r,n,i));return e},[])}function _(n,i,a){var u={};i++;Object.keys(n).forEach(function(e){var r=n[e];if(r instanceof Pair){if(LSymbol.is(r.car,"unquote-splicing")){throw new Error("You can't call `unquote-splicing` "+"inside object")}var t;if(i<a){t=d(r.cdr.car,i,a)}else{t=_evaluate(r.cdr.car,{env:s,dynamic_scope:o,error:c})}u[e]=t}else{u[e]=r}});if(Object.isFrozen(n)){Object.freeze(u)}return u}function p(i,e,r){if(e<r){return new Pair(new Pair(i.car.car,d(i.car.cdr,e,r)),nil)}var n=[];return function e(r){var t=_evaluate(r.car,{env:s,dynamic_scope:o,error:c});n.push(t);if(r.cdr instanceof Pair){return e(r.cdr)}return unpromise(n,function(t){if(t.some(function(e){return!(e instanceof Pair)})){if(i.cdr instanceof Pair&&LSymbol.is(i.cdr.car,".")&&i.cdr.cdr instanceof Pair&&i.cdr.cdr.cdr===nil){return i.cdr.cdr.car}if(!(i.cdr===nil||i.cdr instanceof Pair)){var e="You can't splice atom inside list";throw new Error(e)}if(t.length>1){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(r<t){return new Pair(new LSymbol("unquote"),d(e.cdr,r,t))}if(r>t){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;i<t;i++){n[i]=arguments[i]}n=n.map(function(e){if(e instanceof Pair){return e.clone()}return e});return(r=global_env.get("append!")).call.apply(r,[this].concat(toConsumableArray(n)))},"(append item ...)\n\n Function will create new list with eac argument appended to the end.\n It will always return new list and not modify it's arguments."),"append!":doc("append!",function(){var t=global_env.get("list?");for(var e=arguments.length,r=new Array(e),n=0;n<e;n++){r[n]=arguments[n]}return r.reduce(function(e,r){typecheck("append!",e,["nil","pair"]);if((r instanceof Pair||r===nil)&&!t(r)){throw new Error("append!: Invalid argument, value is not a list")}if(is_null(r)){return e}if(e===nil){if(r===nil){return nil}return r}return e.append(r)},nil)},"(append! arg1 ...)\n\n Destructive version of append, it modify the list in place. It return\n new list where each argument is appened to the end. It may modify\n lists added as arguments."),reverse:doc(function e(r){typecheck("reverse",r,["array","pair","nil"]);if(r===nil){return nil}if(r instanceof Pair){var t=global_env.get("list->array")(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(i<r){if(!n.cdr||n.cdr===nil||n.haveCycles("cdr")){return nil}n=n.cdr;i++}return n.car}else if(t instanceof Array){return t[r]}else{throw new Error(typeErrorMessage("nth",type(t),"array or pair",2))}},"(nth index obj)\n\n Function return nth element of the list or array. If used with different\n value it will throw exception"),list:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return t.reverse().reduce(function(e,r){return new Pair(r,e)},nil)},"(list . args)\n\n Function create new list out of its arguments."),substring:doc(function e(r,t,n){typecheck("substring",r,"string");typecheck("substring",t,"number");typecheck("substring",n,["number","undefined"]);return r.substring(t.valueOf(),n&&n.valueOf())},"(substring string start end)\n\n Function return part of the string starting at start ending with end."),concat:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}t.forEach(function(e,r){return typecheck("concat",e,"string",r+1)});return t.join("")},"(concat . strings)\n\n Function create new string by joining its arguments"),join:doc(function e(r,t){typecheck("join",r,"string");typecheck("join",t,["pair","nil"]);return global_env.get("list->array")(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;n<r;n++){t[n-1]=arguments[n]}var i=construct(unbind(e),toConsumableArray(t.map(function(e){return unbox(e)})));return i},"(new obj . args)\n\n Function create new JavaScript instance of an object."),typecheck:doc(typecheck,"(typecheck label value type [position])\n\n Function check type and throw exception if type don't match.\n Type can be string or list of strings. Position optional argument\n is used to created proper error message."),"unset-special!":doc("unset-special!",function(e){typecheck("remove-special!",e,"string");delete specials.remove(e.valueOf())},"(unset-special! name)\n\n Function remove special symbol from parser. Added by `set-special!`,\n name must be a string."),"set-special!":doc("set-special!",function(e,r){var t=arguments.length>2&&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;i<t;i++){n[i-1]=arguments[i]}typecheck("apply",r,"function",1);var a=n.pop();typecheck("apply",a,["pair","nil"],n.length+2);n=n.concat(global_env.get("list->array").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;i<t;i++){n[i-1]=arguments[i]}n.forEach(function(e,r){typecheck("for-each",e,["pair","nil"],r+1)});var a=(r=global_env.get("map")).call.apply(r,[this,e].concat(n));if(is_promise(a)){return a.then(function(){})}},"(for-each fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments."),map:doc(function e(t){var n=this;for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++){i[a-1]=arguments[a]}typecheck("map",t,"function");var u=global_env.get("list?");i.forEach(function(e,r){typecheck("map",e,["pair","nil"],r+1);if(e instanceof Pair&&!u.call(n,e)){throw new Error("map: argument ".concat(r+1," is not a list"))}});if(i.length===0){return nil}if(i.some(function(e){return e===nil})){return nil}var o=i.map(function(e){return e.car});var c=this.get("parent.frame");var s=this.newFrame(t,o);s.set("parent.frame",c);return unpromise(t.call.apply(t,[s].concat(toConsumableArray(o))),function(r){return unpromise(e.call.apply(e,[n,t].concat(toConsumableArray(i.map(function(e){return e.cdr})))),function(e){return new Pair(r,e)})})},"(map fn . lists)\n\n Higher order function that call function `fn` by for each\n value of the argument. If you provide more then one list as argument\n it will take each value from each list and call `fn` function\n with that many argument as number of list arguments. The return\n values of the function call is acumulated in result list and\n returned by the call to map."),"list?":doc("list?",function(e){var r=e;while(true){if(r===nil){return true}if(!(r instanceof Pair)){return false}if(r.haveCycles("cdr")){return false}r=r.cdr}},'(list? obj)\n\n Function test if value is proper linked list structure.\n The car of each pair can be any value. It return false on cycles."'),some:doc(function r(t,n){typecheck("some",t,"function");typecheck("some",n,["pair","nil"]);if(is_null(n)){return false}else{return unpromise(t(n.car),function(e){return e||r(t,n.cdr)})}},"(some fn list)\n\n Higher order function that call argument on each element of the list.\n It stops when function fn return true for a value if so it will\n return true. If none of the values give true, the function return false"),fold:doc("fold",fold("fold",function(e,r,t){for(var n=arguments.length,i=new Array(n>3?n-3:0),a=3;a<n;a++){i[a-3]=arguments[a]}typecheck("fold",r,"function");i.forEach(function(e,r){typecheck("fold",e,["pair","nil"],r+1)});if(i.some(function(e){return e===nil})){return t}var u=e.call.apply(e,[this,r,t].concat(toConsumableArray(i.map(function(e){return e.cdr}))));return unpromise(u,function(e){return r.apply(void 0,toConsumableArray(i.map(function(e){return e.car})).concat([e]))})}),"(fold fn init . lists)\n\n Function fold is reverse of the reduce. it call function `fn`\n on each elements of the list and return single value.\n e.g. it call (fn a1 b1 (fn a2 b2 (fn a3 b3 '())))\n for: (fold fn '() alist blist)"),pluck:doc(function e(){for(var r=arguments.length,a=new Array(r),t=0;t<r;t++){a[t]=arguments[t]}return function(r){a=a.map(function(e){return e instanceof LSymbol?e.__name__:e});if(a.length===0){return nil}else if(a.length===1){var e=a,t=slicedToArray(e,1),n=t[0];return r[n]}var i={};a.forEach(function(e){i[e]=r[e]});return i}},"(pluck . string)\n\n If called with single string it will return function that will return\n key from object. If called with more then one argument function will\n return new object by taking all properties from given object."),reduce:doc("reduce",fold("reduce",function(r,t,e){var n=this;for(var i=arguments.length,a=new Array(i>3?i-3:0),u=3;u<i;u++){a[u-3]=arguments[u]}typecheck("reduce",t,"function");a.forEach(function(e,r){typecheck("reduce",e,["pair","nil"],r+1)});if(a.some(function(e){return e===nil})){return e}return unpromise(t.apply(void 0,toConsumableArray(a.map(function(e){return e.car})).concat([e])),function(e){return r.call.apply(r,[n,t,e].concat(toConsumableArray(a.map(function(e){return e.cdr}))))})}),"(reduce fn init list . lists)\n\n Higher order function take each element of the list and call\n the function with result of previous call or init and next element\n on the list until each element is processed and return single value\n as result of last call to `fn` function.\n e.g. it call (fn a3 b3 (fn a2 b2 (fn a1 b1 init)))\n for (reduce fn init alist blist)"),filter:doc(function e(r,t){typecheck("filter",r,["regex","function"]);typecheck("filter",t,["pair","nil"]);var i=global_env.get("list->array")(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;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");return t.reduce(function(e,r){return e.gcd(r)})},"(gcd n1 n2 ...)\n\n Function return the greatest common divisor of their arguments."),lcm:doc(function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}typecheck_args("lcm",t,"number");var i=t.length,a=abs(t[0]);for(var u=1;u<i;u++){var o=abs(t[u]),c=a;while(a&&o){a>o?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<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("-: procedure require at least one argument")}typecheck_args("-",r,"number");if(r.length===1){return LNumber(r[0]).sub()}if(r.length){return r.reduce(binaryMathOp(function(e,r){return LNumber(e).sub(r)}))}},"(- n1 n2 ...)\n (- n)\n\n Substract number passed as argument. If only one argument is passed\n it will negate the value."),"/":doc("/",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}if(r.length===0){throw new Error("/: procedure require at least one argument")}typecheck_args("/",r,"number");if(r.length===1){return LNumber(1).div(r[0])}return r.reduce(binaryMathOp(function(e,r){return LNumber(e).div(r)}))},"(/ n1 n2 ...)\n (/ n)\n\n Divide number passed as arguments one by one. If single argument\n is passed it will calculate (/ 1 n1)."),abs:doc("abs",singleMathOp(function(e){return LNumber(e).abs()}),"(abs number)\n\n Function create absolute value from number."),truncate:doc("truncate",function(e){typecheck("truncate",e,"number");if(LNumber.isFloat(e)){if(e instanceof LNumber){e=e.valueOf()}return LFloat(truncate(e))}return e},"(truncate n)\n\n Function return integer value from real number."),sqrt:doc("sqrt",singleMathOp(function(e){return LNumber(e).sqrt()}),"(sqrt number)\n\n Function return square root of the number."),"**":doc("**",binaryMathOp(function(e,r){e=LNumber(e);r=LNumber(r);if(r.cmp(0)===-1){return LFloat(1).div(e).pow(r.sub())}return e.pow(r)}),"(** a b)\n\n Function calculate number a to to the power of b."),"1+":doc("1+",singleMathOp(function(e){return LNumber(e).add(1)}),"(1+ number)\n\n Function add 1 to the number and return result."),"1-":doc(singleMathOp(function(e){return LNumber(e).sub(1)}),"(1- number)\n\n Function substract 1 from the number and return result."),"%":doc("%",function(e,r){typecheck_args("%",[e,r],"number");return LNumber(e).rem(r)},"(% n1 n2)\n\n Function get reminder of it's arguments."),"==":doc("==",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("==",r,"number");return seq_compare(function(e,r){return LNumber(e).cmp(r)===0},r)},"(== x1 x2 ...)\n\n Function compare its numerical arguments and check if they are equal"),">":doc(">",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">",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<e;t++){r[t]=arguments[t]}typecheck_args("<",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 decreasing"),"<=":doc(function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args("<=",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 nonincreasing"),">=":doc(">=",function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++){r[t]=arguments[t]}typecheck_args(">=",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;n<t.length;n++){for(var i=0;i<e[0].length;i++){r.push(e[0][i]+t[n])}}return r}}function combinations(e,r,t){var n=[];for(var i=r;i<=t;++i){var a=[];for(var u=0;u<i;++u){a.push(e)}n=n.concat(allPossibleCases(a))}return n}combinations(["d","a"],2,5).forEach(function(e){var r=e.split("");var t=r.slice().reverse();var n=r.map(function(e){return"(c".concat(e,"r")}).join(" ")+" arg"+")".repeat(r.length);var i="c"+e+"r";global_env.set(i,doc(i,function(e){return t.reduce(function(e,r){typecheck(i,e,"pair");if(r==="a"){return e.car}else{return e.cdr}},e)},"(".concat(i," arg)\n\n Function calculate ").concat(n)))});function reversseFind(e,r){var t=e.split(path.sep).filter(Boolean);for(var n=t.length;n--;){var i=path.join.apply(path,["/"].concat(toConsumableArray(t.slice(0,n+1))));if(r(i)){return i}}}function nodeModuleFind(e){return reversseFind(e,function(e){return fs.existsSync(path.join(e,"node_modules"))})}function is_node(){return typeof global!=="undefined"&&global.global===global}if(is_node()){var nodeRequire=eval("require");var fs=nodeRequire("fs");var path=nodeRequire("path");global_env.set("global",global);global_env.set("self",global);global_env.set("window",undefined$1);global_env.set("__dirname",__dirname);global_env.set("__filename",__filename);global_env.set("require.resolve",doc("require.resolve",function(e){typecheck("require.resolve",e,"string");var r=e.valueOf();return nodeRequire.resolve(r)},"(require.resolve path)\n\n Return path relative the current module."));global_env.set("require",doc("require",function(r){typecheck("require",r,"string");r=r.valueOf();var e=process.cwd();var t;try{if(r.match(/^\s*\./)){t=nodeRequire(path.join(e,r))}else{var n=nodeModuleFind(e);if(n){t=nodeRequire(path.join(n,"node_modules",r))}else{t=nodeRequire(r)}}}catch(e){t=nodeRequire(r)}return patch_value(t,global)},"(require module)\n\n Function to be used inside Node.js to import the module."))}else if(typeof window!=="undefined"&&window===root){global_env.set("window",window);global_env.set("global",undefined$1);global_env.set("self",window)}else if(typeof self!=="undefined"&&typeof WorkerGlobalScope!=="undefined"){global_env.set("self",self);global_env.set("window",undefined$1);global_env.set("global",undefined$1)}function typeErrorMessage(e,r,t){var n=arguments.length>3&&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);t<n.length;t++){var i=slicedToArray(n[t],2),a=i[0],u=i[1];if(e instanceof u){return a}}if(_typeof_1(e)==="object"){if(e.__instance__){e.__instance__=false;if(e.__instance__){if(is_function(e.toType)){return e.toType()}return"instance"}}if(e.constructor){if(e.constructor.__class__){return e.constructor.__class__}if(e.constructor===Object){if(is_iterator(e,Symbol.iterator)){return"iterator"}if(is_iterator(e,Symbol.asyncIterator)){return"async-iterator"}}return e.constructor.name.toLowerCase()}}return _typeof_1(e)}function resolve_promises(e){var r=[];t(e);if(r.length){return a(e)}return e;function t(e){if(is_promise(e)){r.push(e)}else if(e instanceof Pair){if(!e.haveCycles("car")){t(e.car)}if(!e.haveCycles("cdr")){t(e.cdr)}}else if(e instanceof Array){e.forEach(t)}}function n(e){return i.apply(this,arguments)}function i(){i=asyncToGenerator(regenerator.mark(function e(t){var n;return regenerator.wrap(function e(r){while(1){switch(r.prev=r.next){case 0:r.t0=Pair;if(!t.haveCycles("car")){r.next=5;break}r.t1=t.car;r.next=8;break;case 5:r.next=7;return a(t.car);case 7:r.t1=r.sent;case 8:r.t2=r.t1;if(!t.haveCycles("cdr")){r.next=13;break}r.t3=t.cdr;r.next=16;break;case 13:r.next=15;return a(t.cdr);case 15:r.t3=r.sent;case 16:r.t4=r.t3;n=new r.t0(r.t2,r.t4);if(t[__data__]){n[__data__]=true}return r.abrupt("return",n);case 20:case"end":return r.stop()}}},e)}));return i.apply(this,arguments)}function a(e){if(e instanceof Array){return Promise.all(e.map(a))}if(e instanceof Pair&&r.length){return n(e)}return e}}function evaluate_args(e,r){var t=r.env,n=r.dynamic_scope,i=r.error;var a=[];var u=e;markCycles(u);function o(){return a}return function r(){if(u instanceof Pair){var e=_evaluate(u.car,{env:t,dynamic_scope:n,error:i});if(n){e=unpromise(e,function(e){if(is_native_function(e)){return e.bind(n)}return e})}return unpromise(resolve_promises(e),function(e){a.push(e);if(u.haveCycles("cdr")){return o()}u=u.cdr;return r()})}else if(u===nil){return o()}else{throw new Error("Syntax Error: improper list found in apply")}}()}function evaluate_syntax(e,r,t){var n=e.invoke(r,t);return unpromise(resolve_promises(n),function(e){if(e instanceof Pair){e.markCycles()}return quote(e)})}function evaluate_macro(e,r,t){function n(e){if(e instanceof Pair){e.markCycles();return e}return quote(e)}var i=e.invoke(r,t);return unpromise(resolve_promises(i),function e(r){if(r&&r[__data__]||!r||self_evaluated(r)){return r}else{return unpromise(_evaluate(r,t),n)}})}function is_raw_lambda(e){return e[__lambda__]&&!e[__prototype__]&&!e[__method__]&&!is_port_method(e)}function prepare_fn_args(e,r){if(is_bound(e)&&!is_object_bound(e)&&(!lips_context(e)||is_port_method(e))){r=r.map(unbox)}if(!is_raw_lambda(e)&&r.some(is_lips_function)&&!is_lips_function(e)&&!is_array_method(e)){r=r.map(function(i){if(is_lips_function(i)){var e=function e(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++){t[n]=arguments[n]}return unpromise(i.apply(this,t),unbox)};e.prototype=i.prototype;return e}return i})}return r}function apply(i,e){var r=arguments.length>2&&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,") <https://lips.js.org>\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 diff --git a/src/lips.js b/src/lips.js index 1ef898de..e44ebca0 100644 --- a/src/lips.js +++ b/src/lips.js @@ -583,6 +583,7 @@ var special = /([-\\^$[\]()+{}?*.|])/g; return str.replace(special, '\\$1'); } + return str; } // ---------------------------------------------------------------------- // Stack used in balanced function @@ -1818,7 +1819,7 @@ exceptions: { specials: [ /* eslint-disable max-len */ - /^(?:#:)?(?:define(?:-values|-syntax|-macro|-class|-record-type)?|(?:call-with-(?:input-file|output-file|port))|lambda|let*|let-env|try|catch|when|unless|while|syntax-rules|(let|letrec)(-syntax))$/ + /^(?:#:)?(?: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|\*)?)$/ /* eslint-enable */ ], shift: {